PDA

View Full Version : [PHP] Form Variables



NeoDreamer
June 11th, 2006, 05:25 PM
Psuedo code:


$user = $_POST['user'];
$password = $_POST['password'];

if((!$user) or (!$password))
{
// form code
// action = self
}
else
{
// check database for match
// reload page if no match
}

When this page first loads, it will only run the "if" code. On the first try, a user fills out both fields so the page reloads and then runs the "else" code. He fails to provide a valid username and password, so the page reloads a second time. On this second reload, will $user and $password be null?

I'm having the problem that on the second reload, those variables appear to not be null, so NO code is run at all!

tucker
June 11th, 2006, 06:15 PM
$user = $_POST['user'];
$password = $_POST['password'];

if((!$user) or (!$password))
{
// form code
// action = self
}
else
{
// check database for match
// reload page if no match
}


Should work.

CriTiCeRz
June 11th, 2006, 06:19 PM
Looks like someone missed a simple ! sign...

NeoDreamer
June 11th, 2006, 07:47 PM
I'm not asking if it works or not. I'm asking whether the post variable retains it's original value after many reloads of the page.

stoodder
June 11th, 2006, 08:21 PM
I'm not asking if it works or not. I'm asking whether the post variable retains it's original value after many reloads of the page.uhm it depends, i knwo thtwhen i hit f5 to reload apage and it will say that i have to resend the data it will stay the same, imnot so sure about it if you were to use a meta-refresh or something. give it a try lol

NeoDreamer
June 11th, 2006, 09:03 PM
uhm it depends, i knwo thtwhen i hit f5 to reload apage and it will say that i have to resend the data it will stay the same, imnot so sure about it if you were to use a meta-refresh or something. give it a try lol
It's reloading via hitting the post button. The form action=self.

Jeff Wheeler
June 11th, 2006, 09:12 PM
If the form is being resubmit, it'll have the same post headers defined (those in the form).

If not, it'll not retain the post headers.