Frank74 Posted November 25, 2011 Share Posted November 25, 2011 Hi I struggle with something i'm trying to achieve. Maybe this is not the correct approach, i don't know. My goal is to attribute a string of a field of the form to a string variable in order to use this string variable in order to "auto fill" the field of the form previously completed. This is to do what is apparently called a sticky form... First the program attributes the string of a field of the form to a string variable : $EmitterFirstName = $_POST["EmitterFirstName"]; Then in the html form there is a field called "EmitterFirstName", and i want to use the string variable $EmitterFirstName in order to auto fill the field with the string previously typed by the user : <input type="text" name="EmitterFirstName" value="<?php $EmitterFirstName ?>"/> But it doesn't work as expected. Do you have any idea why or maybe an advice on how to code such a thing ? Thanks, Link to comment https://forums.phpfreaks.com/topic/251806-php-string-variable-in-a-html-form-value-parameter/ Share on other sites More sharing options...
russthebarber Posted November 25, 2011 Share Posted November 25, 2011 You need to echo the variable like this: <input type="text" name="EmitterFirstName" value="<?php echo $EmitterFirstName ?>"/> Link to comment https://forums.phpfreaks.com/topic/251806-php-string-variable-in-a-html-form-value-parameter/#findComment-1291220 Share on other sites More sharing options...
Frank74 Posted November 26, 2011 Author Share Posted November 26, 2011 Thanks for the answer russthebarber. It seems to work with a text form : <input type="text" name="EmitterFirstName" value="<?php echo $EmitterFirstName ?>"/> But it doesn't seem to work with a textarea form : <textarea cols="50" rows="6" name="EmitterMessage" value="<?php echo $EmitterMessage ?>"> The form appears empty even if the string variable $EmitterMessage contains a string. Do you have an idea on how to make this work correctly ? Thanks, Link to comment https://forums.phpfreaks.com/topic/251806-php-string-variable-in-a-html-form-value-parameter/#findComment-1291292 Share on other sites More sharing options...
PFMaBiSmAd Posted November 26, 2011 Share Posted November 26, 2011 Text areas don't have value='' attributes. The text goes in between the opening and closing tag - <textarea>content gets echoed here...</textarea> Link to comment https://forums.phpfreaks.com/topic/251806-php-string-variable-in-a-html-form-value-parameter/#findComment-1291300 Share on other sites More sharing options...
Frank74 Posted November 27, 2011 Author Share Posted November 27, 2011 Thank you PFMaBiSmAd, it works well now. Link to comment https://forums.phpfreaks.com/topic/251806-php-string-variable-in-a-html-form-value-parameter/#findComment-1291542 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.