I'm creating an 11 page website all within one PHP file. On this specific part, I'm trying to take usernames from $_POST['regUser'] and put into a "logins" array defined as "$logins = array();" .
When I var_dump the array, all I get is "NULL". I'm certain I'm using the right post names and such. I realize that this code might not be near enough to diagnose my problem but I really hope it is.
Remember, this is all just a fraction of a larger program if it seems weird. This specific piece is supposed to log the user in and show the "userHome" page if they supply the correct password and add their username to the $logins array. Everything other than that is working fine. (I call the function in another part of the program)
I'm going to post a few lines of my code because I believe the problem lies somewhere within them (the whole thing is probably 400+ lines).
$regUser = $_POST['regUser'];
$regPass = $_POST['regPass'];
$goodUsername = array('user1', 'user2');
$goodUserPass = array('user1', 'user2');
$logins = array();
if (isset($_POST['userLog'])) {
if (in_array($regUser, $goodUsername)) {
$key = array_search($regUser, $goodUsername);
}
if($goodUserPass[$key] == $regPass) {
array_push($logins, $regUser);
echo userHome(); return;
}
else {
echo invalidLogin(); return;
}
}
function adLogins() {
echo phpHeader();
echo "<center><h1>User Logins</h1></center><br><br>";
var_dump($logins);
echo phpFooter();
}