Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if statement messages

Status
Not open for further replies.

Sitehelp

Technical User
Joined
Feb 4, 2004
Messages
142
Location
GB
Using a login page can you get a message to appear to say the details they entered are incorrect once they have clicked submit instead of appearing as soon as you load the page up?

if ($num == 1)
header("location: Logged In/WelcomeUserPage.php?ClientID=".$HTTP_POST_VARS['ClientID']."");
echo $_SESSION['ClientID'];
// ... redirect to destination ...
} else {
print "Details either incorrect or not submitted";

I am getting the message "Details either incorrect or not submitted" stragiht away before I have done anything. May be having a pop-up alert would suffice! any help will be much appreciated! Thanks!
 
Hi again,

Good to start another thread... the another one was growing to large..

You can not know if the user enter the info good or bad if you don't query the DB. I use to write the following login page (php) short version:
Code:
<?php
if (isset($_GET[&quot;error&quot;]))
        $error=&quot;Usuario o Password incorrecto&quot;;
echo &quot;<br><br><br>\n&quot;;
 
echo &quot;<form action=\&quot;canlogin.php\&quot; method=POST name=login>\n&quot;;
		echo &quot;Usuario:&quot;;
        echo &quot;<input type=text name=user size=20 class=ent maxlength=15><br><br>\n&quot;;
        echo &quot;Password:&quot;;
        echo &quot;<input type=password name=password class=ent size=20 maxlength=15><br><br>\n&quot;;
        echo &quot;<input name=submit value=Login type=submit><br><br>\n&quot;;
echo &quot;</form>&quot;;
?>

so, canlogin.php will query the DB, if user not foumd will

header(&quot;Location: login.php?error=0&quot;);

Cheers.
 
Cheers! What does the (isset($_GET&quot;error&quot;)) do?
 
it should be $_GET [ &quot;error&quot; ] with no spaces (again).

note that in the canlogin.php you will have a
header(&quot;Location: login.php?error=0&quot;).. it means if user is not valid it will send you to login.php agan but with the variable error=0 and in login.php you will ask &quot;does the variable error exists?&quot; with isset($_GET[ &quot;error&quot; ]), what value has error, it does not matter, the thing is wheter the var exists or not.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top