Try this:
<?php
}
else if($name=='user'&&$password=='pass')
{
// visitor's name and password combination are correct
header("Location: attendace.php"); //redirect page
exit;
}
else
{
// visitor's name and password combination are not correct
echo '<h1>Sorry!</h1>';
echo 'You are not authorized to view this resource.';
}
?>
Silviu
----- Original Message -----
From: Chris Overland
To: [email protected]
Sent: Saturday, July 30, 2005 7:18 PM
Subject: [php_mysql] ELSE IF in a password scheme
I'm stumped. Am writing a password scheme where if
the password is incorrect, a message is echoed to the
screen and if the password is correct, 'else if' takes
you to another .php file. Does anyone have any
pointers on making this work? Am including the code
below. Again, if the password is correct, it takes
you to "attendance.php" otherwise the error echoes to
the screen.
thanks for any replies, Chris
<?php
//create short names for variables
@ $name = $_POST['name'];
@ $password = $_POST['password'];
if(empty($name)||empty($password))
{
//Visitor needs to enter a name and password
?>
<h1>Please Log In</h1>
This page is secret.
<form method="post" action="secretest.php">
<table border="1">
<tr>
<th> Username </th>
<td> <input type="text" name="name"> </td>
</tr>
<tr>
<th> Password </th>
<td> <input type="password" name="password">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Log In">
</td>
</tr>
</table>
</form>
<?php
}
else if($name=='user'&&$password=='pass')
{
// visitor's name and password combination are
correct
echo("<form method='post'
action='attendance.php'>");
}
else
{
// visitor's name and password combination are not
correct
echo '<h1>Sorry!</h1>';
echo 'You are not authorized to view this
resource.';
}
?>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
The php_mysql group is dedicated to learn more about the PHP/MySQL web
database possibilities through group learning.
------------------------------------------------------------------------------
YAHOO! GROUPS LINKS
a.. Visit your group "php_mysql" on the web.
b.. To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--
This message was scanned for spam and viruses by BitDefender.
For more information please visit http://linux.bitdefender.com/
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12h3vss5a/M=362131.6882499.7825260.1510227/D=groups/S=1705375618:TM/Y=YAHOO/EXP=1122749284/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~->
The php_mysql group is dedicated to learn more about the PHP/MySQL web database
possibilities through group learning.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php_mysql/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/