Log in

View Full Version : Help with VERY simple PHP +REP



iUnknown
08-03-2008, 07:48 PM
Hello,

Basically I'm trying to make a form, where you enter a detail into a form field, and submit the form, it then shows a load of text/code in a textarea with the data you submitted at a certain point in the text. This is my code:


<?php
if($_POST['submit'])
{
$port = $_POST['port'];
echo "The text field: <textarea>blah blah blah $port blah blah</textarea>";
}
?>
<form action="index.php" method="post">
<strong class="menu02">Your Port: </strong><br />
<input type="text" name="name" />
<br />
<input type="submit" name="submit" value="Get Code" />
</form>
</div>

For some reason, the bit that should be what they put in the port field of the form, appears as nothing in the textarea. What am I doing wrong, could someone correct me?

Thanks in advance. +rep to the help that works.

Hypertext
08-03-2008, 08:03 PM
your input must be named port in order for $_POST['port'] to be valid.

MrCraig
08-03-2008, 08:06 PM
change


<input type="text" name="name" />


to


<input type="text" name="port" />

Hypertext
08-03-2008, 08:09 PM
Thats what I just said.

iUnknown
08-03-2008, 08:18 PM
Haha I can't believe I made that mistake! Thanks. +rep to both. edit: can't give craig sorry, it asks me to spread it around more first.

Want to hide these adverts? Register an account for free!