PDA

View Full Version : passing data via form


excell
09-09-2002, 12:57 AM
sorry if this already been asked

when i pass data from a form to php page i get undefined variable error. Cant understand why. Do i need to edit somthing in the php.ini file.

<form action="login.php" method="get">
<input type ="text" name="user">
<input type="submit" name submit">
</form>



Next page

....


<?php

print " blah blah $user";

?>

Any ideas i sure its somthing simple

Thanks in advance

Robbie
09-09-2002, 01:15 AM
Try something like this:

<form action="login.php" method="get">
<input type ="text" name="user">
<input type="submit" name submit">
</form>

login.php:
<?
echo"blah bla ".$_GET["user"]." bla bla";
?>


that because the $_GET and $_POST in Php 4.x

(kill me if I'm wrong :D )

excell
09-09-2002, 01:24 AM
Aww

After that change i now get _GET undefined variable
So mabey somthing else ??

firepages
09-09-2002, 07:29 AM
Robbies answer should work the only reason I can think of would be you havd PHP<4.1 and had register_globals turned off in which case ...

<?echo $HTTP_GET_VARS['user'];?>
should work, if not you have other problems:)

+ normally POST is the preffered method for form data

excell
09-09-2002, 08:37 AM
Thank you very much for your help
works fine now