Page 1 of 1

new to php need help to change prepopulated textarea

Posted: Mon Apr 21, 2008 12:20 pm
by gummie
I'm new to php, and need help with a form textarea. My textarea is pre-populated using the following code:

Code: Select all

<textarea name="Rqmnts" cols="80" rows="5" id="Rqmnts"><?php echo $producttitle; ?><?= @$_GET["Requirements"] ?></textarea>
The problem is, I want to replace the pre-populated value ($producttitle;) if a user clicks on a URL that has a string using

Code: Select all

<a href="?Requirements=Some String for specific product name">
I tried using the above code, but both values display in the form textarea.

Any help would be greatly appreciated, as I've search all over internet trying to find a solution.

Thanks

Re: new to php need help to change prepopulated textarea

Posted: Mon Apr 21, 2008 12:30 pm
by John Cartwright

Code: Select all

 
<?php
if (isset($_GET['Requirements'])) {
   $producttitle = htmlspecialchars($_GET['Requirements']); //make sure they don't inject html
}
?>
 
<textarea name="Rqmnts" cols="80" rows="5" id="Rqmnts"><?php echo $producttitle; ?></textarea>
;)

Re: new to php need help to change prepopulated textarea

Posted: Mon Apr 21, 2008 12:56 pm
by gummie
Thank you so much!

Worked perfectly and saved me so much time. :D