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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.