lfernando Posted August 27, 2010 Share Posted August 27, 2010 Hi there! I am wondering if anyone knows how to handle strings that contain form fields, so when the form is submitted the fields inside the string are updated. For example say i have the following $string: please enter your username: <input type=text size=50 name=username value=" "> When I display it on the browser, inside of a form, it displays the blank text field. Say the user enters a value in the text field, "John", and hits submit. I need the $string to be updated to the following: please enter your user name: <input type=text size=50 value="John"> I know it sounds wierd but I need the form to be inside of the string! Thanks in advance for any help! Quote Link to comment Share on other sites More sharing options...
Vince889 Posted August 27, 2010 Share Posted August 27, 2010 Hi there! I am wondering if anyone knows how to handle strings that contain form fields, so when the form is submitted the fields inside the string are updated. For example say i have the following $string: please enter your username: <input type=text size=50 name=username value=" "> When I display it on the browser, inside of a form, it displays the blank text field. Say the user enters a value in the text field, "John", and hits submit. I need the $string to be updated to the following: please enter your user name: <input type=text size=50 value="John"> I know it sounds wierd but I need the form to be inside of the string! Thanks in advance for any help! I'm not understanding... you want the string to read this? $string = "please enter your user name: <input type=text size=50 value='John'>"; Quote Link to comment Share on other sites More sharing options...
lfernando Posted August 27, 2010 Author Share Posted August 27, 2010 Yes, currently my $string (which is an entry in a database) reads this please enter your username: <input type=text size=50 name=username value=" "> I echo this $string as part of a form. Upon submitting the form, i want this $string to read this please enter your username: <input type=text size=50 name=username value="John"> Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted August 28, 2010 Share Posted August 28, 2010 Will this help you? $username = $_POST['username']; //get the value of the submitted html form $string = 'please enter your user name: <input type="text" size=50 value="'.$username.'">'; //put the value inside the string Hope it works for you. Il have changed the " with ' at the outside of the string btw, and added " " around text. If you have troubles with this let me know ill add some more code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.