new to php need help to change prepopulated textarea

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gummie
Forum Newbie
Posts: 2
Joined: Mon Apr 21, 2008 11:44 am

new to php need help to change prepopulated textarea

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: new to php need help to change prepopulated textarea

Post 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>
;)
gummie
Forum Newbie
Posts: 2
Joined: Mon Apr 21, 2008 11:44 am

Re: new to php need help to change prepopulated textarea

Post by gummie »

Thank you so much!

Worked perfectly and saved me so much time. :D
Post Reply