Re: Keeping existing data in textarea's

From: Date: Mon, 03 Mar 2003 18:59:54 +0000
Subject: Re: Keeping existing data in textarea's
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-137944@lists.php.net to get a copy of this message
> Hi, I have a developed a simple Helpdesk for our small company. When users > log calls they get an alert message warning them that they must fill in all > the fields if they have missed a field. At the moment if they happen to > forget a field, they receive the alert message, but then have to start all > over again. How do I keep the existing data in the textareas from > dissapearing after the alert message? Well, when they submit the form, whatever they typed is going to be in $_POST['name_of_textarea'], right? (or $_GET...) To put that value back into a textarea, do something like this: <textarea name="whatever"><?php if(isset($_POST['whatever'])) { echo $_POST['whatever']; } ?></textarea> I'll assume you use the same form for entering if there is an error. the first time this form is displayed, $_POST['whatever'] will not be set, so the <textarea> will be blank. After it's submitted, then the value will be filled back in. ---John Holmes...

« previous php.general (#137944) next »