Page 1 of 1
URL sending the parameter but php does not get it
Posted: Mon Feb 02, 2004 1:02 am
by anjanesh
I have this :
Code: Select all
<form action="test.php">
<input name=username>
<input type=submit value="Test" name=but>
</form>
On clicking the test button after entering Hello in the text box url is
http://localhost/anjanesh/test.php?user ... o&but=Test.
The test.php code is
But nothing gets printed. Why ?
Thanks
Posted: Mon Feb 02, 2004 1:34 am
by Sevengraff
there was a sticky topic on this, but I dont see it now.
Anyway, you are probally using a newer version of PHP with register_globals to off. To get the value you need to use $_POST['username'], as you are sending the data through a form. To get data via the url like example.com/index.php?action=dothis, then the code $_GET['action'] would return "dothis".
I'm very sleepy right now so I hope that made sense.
Thanks - but IIS6 is recognizing it ?
Posted: Mon Feb 02, 2004 2:07 am
by anjanesh
Thanks - Did not know about that but in that case how is IIS6 managing this without $_GET[] etc. All this time I was using $username in IIS6 ?
Thanks a lot
Posted: Mon Feb 02, 2004 4:58 am
by twigletmac
You must have had register_globals turned on on your other server, this has nothing to do with the web server being used and everything to do with how PHP is set up.
Mac
Posted: Mon Feb 02, 2004 6:34 am
by Nay
You might want to note not to be using $_GET for a login form since the data passed will be jotted down in the history of the browser thus raising security problems.
Just a note.
-Nay
Re: URL sending the parameter but php does not get it
Posted: Mon Feb 02, 2004 6:48 am
by patrikG
anjanesh wrote:
Code: Select all
<form action="test.php">
<input name=username>
<input type=submit value="Test" name=but>
</form>
Also, make sure that you specify the method (either POST or GET) in the form-tag:
Code: Select all
<form action="test.php" method="GET">
<input name=username>
<input type=submit value="Test" name=but>
</form>