Jump to content

form field inside string?


lfernando

Recommended Posts

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! :)

 

Link to comment
Share on other sites

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'>";

Link to comment
Share on other sites

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">

Link to comment
Share on other sites

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.  8)

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.