Ok so I have been working on a little php (with my VERY brief background). The goal of the script is to take a students username and password, and then show them there grades. However when I test the script, it just falls through and redirects to the final else statement and asks me to put in the correct username and password (ie it does not see that the input is correct). I know the code I have below is "simplistic" but I want to see how to get it to work this way first, and then make the code more "usable". If the code is however "beyond fixing" just let me know. I have included the form and the php. Thanks in Advance!
//The form
<form action="http://daytona.birdnest.org/~acc.joshid2/csci101labs/b/pC.php" method="post" align="center">
<span class="auto-style3">Username:</span> <input type="Uname" name="Uname" Size="10" /> <br>
<span class="auto-style3">Password:</span> <input type="password" name="Pword" Size="10" /> <br>
<input type="submit" />
</form>
//the php
<html>
<head>
<title> pC </title>
</head>
<body>
<h1 align="center"> PROCESSING </h1>
<br>
<?php
$var_inputPassword = ($_POST["Pword"]);
$var_inputUsername = ($_POST["Uname"]);
?>
<?php
$myFile = "passwords.txt";
$fh = fopen($myFile, 'r');
$var_data = fread($fh, filesize($myFile));
fclose($fh);
$var_Plist = explode("\n",$var_data);
?>
<?php
$Pkeys = array(
0=>$var_Plist[0],
1=>$var_Plist[1],
2=>$var_Plist[2],
3=>$var_Plist[3],
4=>$var_Plist[4],
5=>$var_Plist[5],
6=>$var_Plist[6],
7=>$var_Plist[7],
8=>$var_Plist[8],
9=>$var_Plist[9],
10=>$var_Plist[10],
11=>$var_Plist[11],
12=>$var_Plist[12],
13=>$var_Plist[13],
14=>$var_Plist[14],
15=>$var_Plist[15],
16=>$var_Plist[16],
17=>$var_Plist[17],
18=>$var_Plist[18],
19=>$var_Plist[19],
20=>$var_Plist[20],
21=>$var_Plist[21],
22=>$var_Plist[22],
23=>$var_Plist[23],
24=>$var_Plist[24],
25=>$var_Plist[25],
26=>$var_Plist[26],
27=>$var_Plist[27],
28=>$var_Plist[28],
29=>$var_Plist[29],
30=>$var_Plist[30],
31=>$var_Plist[31]);
?>
<?php
$myFile = "usrname.txt";
$fh = fopen($myFile, 'r');
$var_data = fread($fh, filesize($myFile));
fclose($fh);
$var_Plist = explode("\n",$var_data);
?>
<?php
$Ukeys = array(
0=>$var_Ulist[0],
1=>$var_Ulist[1],
2=>$var_Ulist[2],
3=>$var_Ulist[3],
4=>$var_Ulist[4],
5=>$var_Ulist[5],
6=>$var_Ulist[6],
7=>$var_Ulist[7],
8=>$var_Ulist[8],
9=>$var_Ulist[9],
10=>$var_Ulist[10],
11=>$var_Ulist[11],
12=>$var_Ulist[12],
13=>$var_Ulist[13],
14=>$var_Ulist[14],
15=>$var_Ulist[15],
16=>$var_Ulist[16],
17=>$var_Ulist[17],
18=>$var_Ulist[18],
19=>$var_Ulist[19],
20=>$var_Ulist[20],
21=>$var_Ulist[21],
22=>$var_Ulist[22],
23=>$var_Ulist[23],
24=>$var_Ulist[24],
25=>$var_Ulist[25],
26=>$var_Ulist[26],
27=>$var_Ulist[27],
28=>$var_Ulist[28],
29=>$var_Ulist[29],
30=>$var_Ulist[30],
31=>$var_Ulist[31]);
?>
<hr />
<?php
if (in_array($var_inputPassword, $Pkeys))
{
//redirect to url
if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student1")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student2")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student3")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student4")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student5")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student6")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student7")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student8")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student9")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student10")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student11")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student12")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student13")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student14")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student15")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student16")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student17")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student18")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student19")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student20")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student21")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student22")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student23")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student24")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student25")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student26")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student27")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student28")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student29")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "student30")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=sOmeUrL">');
}
}
else if (in_array($var_inputUsername, $Ukeys))
{
if ($var_inputUsername == "joshid2")
{
echo ( '<meta http-equiv="REFRESH" content="0;url=http://www.google.com">');
}
}
}
else
{
//redirect to index2.html
echo ( '<meta http-equiv="REFRESH" content="0;url=http://www.birdnest.org/joshid2/bgradesR.html">');
}
?>
</body>
</html>