Forum Moderators: coopster

Message Too Old, No Replies

Forms, froms, and more forms

         

electricocean

2:01 am on May 17, 2005 (gmt 0)

10+ Year Member



Hi,

How do you do a post (like the webmasterworld's) that you can view what has been posted but keep what the person typed in, in the text area.

Thanks,

electricocean

crashomon

2:44 am on May 17, 2005 (gmt 0)

10+ Year Member



Are you asking if its possible to pass the values to a new page with all text fields still populated?

Or are you asking something else?

saoi_jp

3:22 am on May 17, 2005 (gmt 0)

10+ Year Member



<textarea name="post" cols="55" rows="15">put the text here</textarea>

electricocean

4:41 am on May 17, 2005 (gmt 0)

10+ Year Member



I mean I have an admin section for the site. Once you're logged in you can add news which will be displayed on the first page of the site there is a text area where you type in the news then you can either click "Preview" or "Add" When click "Preview it shows what the user types in on top with $_POST['news'], but then it deletes it from the textarea so the user cannot sumbit.

My Question is how would I make the news the user typed in still inside the text area when the user clicks on "PREVIEW" becuase it doesn't.

would I do this:

<textaea value="<?php echo $news;?>"> or something

Hope tis helps!

electricocean

PieSocial

5:04 am on May 17, 2005 (gmt 0)

10+ Year Member



All of my scripts add a location header to the page after a post. That way the user is redirected again after the script executes to ensure there is nothing that is Re-posted if the user refreshes a page.

My solution to the keeping content on the page has been to make an array of items, throw them into SESSION, and then unset the SESSION I created when the next page loads. Then populate the fields.

It's clean and I don't think there is anything wrong with doing things this way.

willybfriendly

5:21 am on May 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<textaea value="<?php echo $news;?>"> or something

Close. Try:

<textarea name="news" cols="55" rows="15"><? echo $_POST[news];?></textarea>

You could also echo $news to a hidden field and just not show the text box. Then submit would post the hidden field to the DB, and edit would bring up the tex box again, where you would simply echo $news as I showed above.

WBF

(Don't forget to validate $news before you do anything with it.)

PieSocial

5:26 am on May 17, 2005 (gmt 0)

10+ Year Member



ps. Sinse you have the data on the next page already, I would simply use <textarea><?php print($_POST['news']);?>"</textarea> Cheers.

Darn beaten!