Forum Moderators: coopster

Message Too Old, No Replies

i could not get value from the form

i could not get value from the form

         

xbl01234

10:23 pm on Dec 17, 2006 (gmt 0)

10+ Year Member



Hello;
I tried to print out some value which from a submit form, but i could not, could you tell me why, please.


<html>

<body>
<ceneter>
<form action="submitR.php" method="post">
User Name:
<input type="text" name="UserName" maxlength=2><br>

Topic:
<input type="text" name="Topic" maxlength=2> <br>

Content:<br>
<TEXTAREA name="content" clos=50 rows=10 onkeyup="this.value = this.value.slice(0, 200)"></TEXTAREA>
<br>
<INPUT type="submit" value="submit"> <INPUT type="reset">
</form>
</ceneter>


</body>

</html>


in the submitR.php file


<?

echo "$REQUEST_['topic']";
echo "$REQUEST_['content']";
echo "$REQUEST_['username']";

?>

hughie

10:31 pm on Dec 17, 2006 (gmt 0)

10+ Year Member



a simple one to fix, your underscore is in the wrong place and the variables are in the same case as the form elements.

echo $_REQUEST['Topic'];
echo $_REQUEST['content'];
echo $_REQUEST['UserName'];

When i want to see what's going on i tend to use:

print_r($_REQUEST); as it'll spit out everything coming from the form.

cheers,
hughie

eelixduppy

10:45 pm on Dec 17, 2006 (gmt 0)



The fix is correct and will work, however I suggest that you use $_POST instead of $_REQUEST so that only post variables will be used (not get or cookies). It's good practice :)

xbl01234

11:00 pm on Dec 17, 2006 (gmt 0)

10+ Year Member



Thanks a lot.