I keep getting the same errors when i try to run the script.
Code:
Notice: Undefined index: username in /u21/www/final2/index.php on line 49
Notice: Undefined index: password in /u21/www/final2/index.php on line 49
Notice: Undefined index: LOGGED_IN in /u21/scsu/c/chaputs1/www/final2/index.php on line 44
Obviously this is because of the fact the variables arent defined until later.
Code:
<?php if ($_SESSION['LOGGED_IN'] == true) {
echo '<ul>';
echo '<li>Welcome ' . $_SESSION['username'] . ' ' . $_SESSION['password'] . '</li>';
echo '<li><a href="/manage.php">Manage</a></li>';
echo '<li><a href="/logout.php">Logout</a></li>';
echo '</ul>';
} else { ?>
<form id="login" action="loginauth.php" method="post">
<label for="username">User Name: <input type="text" id="username" name="username" value="" /></label>
<label for="password">Password:
<input type="password" id="password" name="password" value="" />
</label>
<input type="hidden" name="login" value="1" />
<input class="submit" type="submit" name="submit" />
<p>Not a member? <a href="/register.php">Click here to create an account.</a></p>
</form>
<!-- end login -->
¢<?php } ?>
I am not sure the correct way to declare these variables. I believe loginauth.php is correct but just for the sake ill post the code below.
Code:
if ($num_rows <= 0) {
echo "Sorry, there is no username $username with the specified password.<br>";?>
<p>
<?php
echo "Please Wait...";
exit;
} else {
setcookie("loggedin", "TRUE", time()+(3600 * 24));
setcookie("mysite_username", "$username");
?>
<center>
<?php
echo "Welcome";
$_SESSION['LOGGED_IN'] = true;
$_SESSION['USER_NAME'] = "$username";
header( 'Location: /index.php' ) ;
?>
</center>
<?php
}
?>
Thank you very much for your help.
Bookmarks