0

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>
3
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by atticusr5
0

hielo, thanks for catching that for me. I still have the problem but that was clearly an issue no doubt. I will keep at it but thanks for that again.

Here is the code in its current form:

<html>
<head>
<title> pC </title>
</head>
<body>
<h1 align="center"> PROCESSING </h1>
<br>
<?php

	$var_inputPassword = ($_POST["Pword"]);
	$var_inputUsername = ($_POST["Uname"]);
?>

<?php

$myFile1 = "passwords.txt";
$fh1 = fopen($myFile1, 'r');
$var_data1 = fread($fh1, filesize($myFile1));
fclose($fh1);
$var_Plist = explode("\n",$var_data1);
?>

<?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

$myFile2 = "usrname.txt";
$fh2 = fopen($myFile2, 'r');
$var_data2 = fread($fh2, filesize($myFile2));
fclose($fh2);
$var_Ulist = explode("\n",$var_data2);
?>

<?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)) 
	{ 
		if (in_array($var_inputUsername, $Ukeys))
		{
			if ($var_inputUsername == "student1")
			{
				echo ( '<meta http-equiv="REFRESH" content="0;url=http://www.mytjnow.com">');
			}
		}
		else if (in_array($var_inputUsername, $Ukeys))
		{
			if ($var_inputUsername == "student2")
			{
				echo ( '<meta http-equiv="REFRESH" content="0;url=http://www.mytjnow.com">');
			}
		}
		else if (in_array($var_inputUsername, $Ukeys))
		{
			if ($var_inputUsername == "student3")
			{
				echo ( '<meta http-equiv="REFRESH" content="0;url=http://www.mytjnow.com">');
			}
		}
		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
	{
		echo ( '<meta http-equiv="REFRESH" content="0;url=http://www.birdnest.org/joshid2/bgradesR.html">');
		
	}
?>

</body>
</html>
1

Wow, quite a pile of code. We can't see what is in the files that you are reading in. That could be a source of a problem or not (but probably not at this point). It seems that on line 67 it should have been $var_Ulist = ...

On line 109 you should probably dump the arrays (print_r) and the two variables (with an echo) so you can verify that the data is what you think it is.

Your Else If statements at 120, 127 and so forth will never be executed / true. If the statement at line 113 is true, then the statements immediately following the IF will be executed and it will ignore the else if's. On the other hand, if the IF statement at line 113 is false, then all of the Else If statements will also be false because they have the same condition as the initial IF.

0

oh im sorry ill include the files, and Ill check up on your suggestions in the morning!

Thanks again.

Username file:

joshid2
student1
student2
student3
student4
student5
student6
student7
student8
student9
student10
student11
student12
student13
student14
student15
student16
student17
student18
student19
student20
student21
student22
student23
student24
student25
student26
student27
student28
student29
student30

passwords file:

cNmeKFBc
NnbVDctt
SajsJCxg
plqXuIvf
xVKUHQMa
DYWJHAVl
wWIvoAaD
TOKNEXZp
MLVTsBDW
OZiGRMLQ
ReiprDpS
cBUzMVzi
dgGSVkvo
DUGNYjSk
wwcwsIzP
jzWnGbgr
zgXriCsJ
HNlSsjCx
QIXFBLLs
yBFbxgIP
WMncFCYj
LyKQFiTO
ZKWiXMzl
dMZHCUeo
xLmRBXlC
CWoxkEth
DKkFdWEV
MfCDfCLP
QBbJqjwK
uaYMhUiZ
AAAAAAAA
0

Ok, using this bit of code:

<hr />
<?php
echo ('Password Array');
echo ('<br>');
print_r ($Pkeys);
echo ('<br><br>');
echo ('Username Array');
echo ('<br>');
print_r ($Ukeys);
echo ('<br><br>');
echo ('User Input');
echo ($var_inputUsername);
echo ('<br>');
echo ($var_inputPassword);
?>
<hr />

I was able to confirm the data from the php. Here is the output I got:

Password Array
Array ( [0] => cNmeKFBc [1] => NnbVDctt [2] => SajsJCxg [3] => plqXuIvf [4] => xVKUHQMa [5] => DYWJHAVl [6] => wWIvoAaD [7] => TOKNEXZp [8] => MLVTsBDW [9] => OZiGRMLQ [10] => ReiprDpS [11] => cBUzMVzi [12] => dgGSVkvo [13] => DUGNYjSk [14] => wwcwsIzP [15] => jzWnGbgr [16] => zgXriCsJ [17] => HNlSsjCx [18] => QIXFBLLs [19] => yBFbxgIP [20] => WMncFCYj [21] => LyKQFiTO [22] => ZKWiXMzl [23] => dMZHCUeo [24] => xLmRBXlC [25] => CWoxkEth [26] => DKkFdWEV [27] => MfCDfCLP [28] => QBbJqjwK [29] => uaYMhUiZ [30] => AAAAAAAA [31] => ) 

Username Array
Array ( [0] => joshid2 [1] => student1 [2] => student2 [3] => student3 [4] => student4 [5] => student5 [6] => student6 [7] => student7 [8] => student8 [9] => student9 [10] => student10 [11] => student11 [12] => student12 [13] => student13 [14] => student14 [15] => student15 [16] => student16 [17] => student17 [18] => student18 [19] => student19 [20] => student20 [21] => student21 [22] => student22 [23] => student23 [24] => student24 [25] => student25 [26] => student26 [27] => student27 [28] => student28 [29] => student29 [30] => student30 [31] => ) 

User Inputjoshid2
AAAAAAAA

I think that looks right, I have never used print_r for arrays so I guess it must be just printing out each array location and its marker. Thanks for the tip chrishea! Ill keep at it!

0

Ok so I took everyones advice and basically went back to just checking output. I have managed to confirm that data is in the arrays and that the user input from the forms is also passing through to the php. (you can try it yourself @ http://www.birdnest.org/joshid2/bgrades.html -->username: student1 --->password: AAAAAAAA).

I also put in two if statements, to see if the userinput is found in the arrays. The username is correctly found, but the password is not. So this must be one of the reasons I did not get the correct function. However I can't find the bug, is it a simple syntax error? Thanks again here is 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

$myFile1 = "passwords.txt";
$fh1 = fopen($myFile1, 'r');
$var_data1 = fread($fh1, filesize($myFile1));
fclose($fh1);
$var_Plist = explode("\n",$var_data1);
?>

<?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

$myFile2 = "usrname.txt";
$fh2 = fopen($myFile2, 'r');
$var_data2 = fread($fh2, filesize($myFile2));
fclose($fh2);
$var_Ulist = explode("\n",$var_data2);
?>

<?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
echo ('Password Array');
echo ('<br>');
print_r ($Pkeys);
echo ('<br><br>');
echo ('Username Array');
echo ('<br>');
print_r ($Ukeys);
echo ('<br><br>');
echo ('User Input');
echo ($var_inputUsername);
echo ('<br>');
echo ($var_inputPassword);
?>
<hr />
<?php

	if (in_array($var_inputPassword, $Pkeys))
	{
		echo ('password is being found in password array');
	}
	echo ('<br><br>');
	if (in_array($var_inputUsername, $Ukeys))
	{
		echo ('username is being found in username array');
	}
?>

</body>
</html>
0

(you can try it yourself @ http://www.birdnest.org/joshid2/bgrades.html -->username: student1 --->password: AAAAAAAA).

a. I went to that page and it has no field to enter the username
b. Based on your username and password arrays, student1 corresponds with password cNmeKFBc, NOT AAAAAAAA. In other words,
item 0 in $Ukeys should correspond to item 0 in $Pkeys
item 1 in $Ukeys should correspond to item 1 in $Pkeys
...
item 31 in $Ukeys should correspond to item 31 in $Pkeys

0

hielo, sorry about that, I had changed the html while doing some tests last night. You were correct, the problem I was having was because I was using the first username and the last password. I thought the way I had written the code, any combination would work but I guess not.

Again thanks to everyone!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.