Hey. I'm designing/coding the website for my school's theater program and I've been asked to have diferent sections for diferent user types.
Well I'm having trouble logging them in.
The form looks like this:
<form action="process_login.php" method="get">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><center><input type="text" name="userLogin" value="Login Name" size="24"></center></td>
</tr>
<tr>
<td><center><input type="password" name="userPassword" value="Password" size="24"></center></td>
</tr>
<tr>
<td><center><select name="userGroup">
<option></option>
<option value="student">Current Student</option>
<option value="officer">Current Officer</option>
<option value="srManager">Current Sr. Manager</option>
<option value="staff">Current Staff</option>
<option value="alumni">Alumni</option>
<option value="parents">Parent</option>
<option value="fan">Fan</option>
</select></center></td>
</tr>
<tr>
<td><center><input type="submit" name="submit" value="Login"> <input type="reset" name="reset" value="Reset Form"></center></td>
</tr>
</table>
</form>
and "process_login.php" looks like this:
<?php
require ('includes/config.php');
if (empty($userLogin))
{
print "You forgot to type your login name in the form. Please go back and correct the mistake.";
}
elseif (empty($userPassword))
{
print "You forgot to type your password in the form. Please go back and correct the mistake.";
}
elseif (empty($userGroup))
{
print "You forgot to specify your group in the form. Please go back and correct the mistake.";
}
else
{
if ($db_connect == TRUE)
{
if ($userGroup === student)
{
$student_login = mysql_query("SELECT userPassword FROM usersStudent WHERE userLogin === $userLogin");
if ($student_login == TRUE)
{
header("Location: student_admin.php?userLogin");
}
else
{
print "You could not be logged in, please try again. If you have not yet registered, please do so.";
}
}
elseif ($userGroup === officer)
{
$officer_login = mysql_query("SELECT userPassword FROM usersOfficer WHERE $userLogin === userLogin");
if ($officer_login == TRUE)
{
header("Location: officer_admin.php?userLogin");
}
else
{
print "You could not be logged in, please try again. If you have not yet registered, please do so.";
}
}
elseif ($userGroup === srManager)
{
$srManager_login = mysql_query("SELECT userPassword FROM usersSrManager WHERE $userLogin === userLogin");
if ($srManager_login == TRUE)
{
header("Location: srmanager_admin.php?userLogin");
}
else
{
print "You could not be logged in, please try again. If you have not yet registered, please do so.";
}
}
elseif ($userGroup === staff)
{
$staff_login = mysql_query("SELECT userPassword FROM usersStaff WHERE $userLogin === userLogin");
if ($staff_login == TRUE)
{
header("Location: staff_admin.php?userLogin");
}
else
{
print "You could not be logged in, please try again. If you have not yet registered, please do so.";
}
}
elseif ($userGroup === alumni)
{
$alumni_login = mysql_query("SELECT userPassword FROM usersAlumni WHERE $userLogin === userLogin");
if ($alumni_login == TRUE)
{
header("Location: alumni_admin.php?userLogin");
}
else
{
print "You could not be logged in, please try again. If you have not yet registered, please do so.";
}
}
elseif ($userGroup === parents)
{
$parent_login = mysql_query("SELECT userPassword FROM usersParent WHERE $userLogin === userLogin");
if ($parent_login == TRUE)
{
header("Location: parent_admin.php?userLogin");
}
else
{
print "You could not be logged in, please try again. If you have not yet registered, please do so.";
}
}
elseif ($userGroup === fan)
{
$fan_login = mysql_query("SELECT userPassword FROM usersFan WHERE $userLogin === userLogin");
if ($fan_login == TRUE)
{
header("Location: fan_admin.php?userLogin");
}
else
{
print "You could not be logged in, please try again. If you have not yet registered, please do so.";
}
}
else
{
print "You could not be logged in, please try again. If you have not yet registered, please do so.";
}
}
else
{
print "Sorry, the server could not log you in. The database maybe down. Please try again and if the problem is persistant, then please contact the webmaster.";
}
mysql_close($db_connect);
}
?>
The first few "if statements" work. It makes sure that I have included everything into the form for login. The problem is... it won't log me in. It always prints: "You could not be logged in, please try again. If you have not yet registered, please do so."
Do you guys have any ideas? The login info that I am using is in a table called 'usersStudent', so my login should work with the first option.
Thanks!