Jump to content

Echoing user input's multiple times on the same page?


iStriide

Recommended Posts

I need to know how to echo multiple things on the same page. If you do understand the last line then don't read this next part.

 

So say if had just a textbox and a submit button. I already know how to make it where they type something and they hit submit and echo's to the page. But after it echos I want to know how to make it where if they entered in another body of text

it would enter on the same page right under the last echo, or the last thing they typed. So if you could help me with this or just post a code for me that would be nice.

Link to comment
Share on other sites

so you have page 1

<form method="post" action="page2.php">
<input type="text" name="frmUserField" value="" />
<input type="submit" name="btnSubmit" value="Submit me now!!" />
</form>

 

So on Page 2 you want to create a variable

//Proper method
$strUserValue = '';
if(isset($_POST['frmUserField']){
$strUserValue = $_POST['frmUserField'];
}

echo $strUserValue;

 

You can echo $strUserValue as many times as you want.

 

 

You name a Variable, such as 'strUserValue' (I put str, int, bln, dt in front of a variable so I know at a glance what data type it is)

 

You then add a value to the variable

 

the Variable is available throughout the page your on, it doesn't lose its value by echoing it.

 

if you change pages, then the variable is left behind and forgotten will be left behind

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.