All right. Now I’m mad.
I just posted this and got logged out and it didn’t appear, so let’s try it again.
Bottom Line:
I have 2 nearly identical pages, 1 works, and 1 does not.
Section 1 “login.php”:
[code=php]
<?php
ob_start();
require (‘templates/template1.html’);
session_start();
?>
<script language=”Javascript” type=”text/javascript”>
<!–
function validForm(passForm) {
if (passForm.username.value == “”) {
alert(“Please enter your username.”)
passForm.username.focus()
return false
}
if (passForm.pass.value == “”) {
alert(“Please enter your password.”)
passForm.pass.focus()
return false
}
if (passForm.pass.value != passForm.confirm.value) {
alert(“Entered passwords did not match.”)
passForm.pass.focus()
passForm.pass.select()
return false
}
return true
}
// –>
</script>
<h1 align=”center”>Log In</h1>
<?php
if (isset ($_SESSION[‘username’])) {
print (“<p>Error! You are already logged in!</p>”);
} else {
?>
<p>Please note that “Character Name” refers to your Animal Crossing character’s name.</p>
<form action=”loggedin.php” method=”post” onsubmit=”return validForm(this)”>
<p>Username: <input type=”text” name=”username” /></p>
<p>Character Name: <input type=”text” name=”character” /></p>
<p>Password: <input type=”password” name=”pass” /></p>
<p>Confirm Password: <input type=”password” name=”confirm” /></p>
<p><input type=”submit” value=”Log In” /></p>
</form>
<?php
}
require (‘templates/template2.html’);
ob_end_flush();
?>
Section 1 “loggedin.php”:
[code=php]
<?php
ob_start();
require (‘templates/template1.html’);
session_start();
$username = $_POST[‘username’];
$password = $_POST[‘pass’];
$confirm = $_POST[‘confirm’];
$character = $_POST[‘character’];
if ($password != $confirm) {
print (“<p>Passwords did not match. Please go back and try again. P.S. You don’t have javascript enabled.</p>”);
} else {
switch ($username) {
case “Stevos”:
switch ($password) {
case “sarahatamian”:
$_SESSION[‘username’] = $username;
$_SESSION[‘password’] = $password;
$_SESSION[‘character’] = $character;
print (“<p>Thank you. You are now logged in as ” . $_SESSION[‘username’] . “.</p>”);
header (‘Location: index.php’);
exit();
break;
default:
print (“<p>That password does not match the username you entered.</p>”);
break;
}
break;
case “Rhalyth”:
switch ($password) {
case “leeroy666”:
$_SESSION[‘username’] = $username;
$_SESSION[‘password’] = $password;
$_SESSION[‘character’] = $character;
print (“<p>Thank you. You are now logged in as ” . $_SESSION[‘username’] . “.</p>”);
header (‘Location: index.php’);
exit();
break;
default:
print (“<p>That password does not match the username you entered.</p>”);
break;
}
break;
case “Gayle”:
switch ($password) {
case “sarahatamian”:
$_SESSION[‘username’] = $username;
$_SESSION[‘password’] = $password;
$_SESSION[‘character’] = $character;
print (“<p>Thank you. You are now logged in as ” . $_SESSION[‘username’] . “.</p>”);
header (‘Location: index.php’);
exit();
break;
default:
print (“<p>That password does not match the username you entered.</p>”);
break;
}
default:
print (“<p>We have no record of that username. If you are not an admin, you will not be able to sign in here.</p>”);
break;
}
}
require (‘templates/template2.html’);
ob_end_flush();
?>
Section 2 “login.php”:
[code=php]
<?php
ob_start();
require (‘templates/template1.html’);
session_start();
?>
<script language=”Javascript” type=”text/javascript”>
<!–
function validForm(passForm) {
if (passForm.username.value == “”) {
alert(“Please enter your username.”)
passForm.username.focus()
return false
}
if (passForm.pass.value == “”) {
alert(“Please enter your password.”)
passForm.pass.focus()
return false
}
if (passForm.pass.value != passForm.confirm.value) {
alert(“Entered passwords did not match.”)
passForm.pass.focus()
passForm.pass.select()
return false
}
return true
}
// –>
</script>
<h1 align=”center”>Log In</h1>
<?php
if (isset ($_SESSION[‘uhusername’])) {
print (“<p>Error! You are already logged in!</p>”);
} else {
?>
<p>Please note that “Character Name” refers to your Animal Crossing character’s name.</p>
<form action=”http://stevos404.t35.com/uh/loggedin.php” method=”post” onsubmit=”return validForm(this)”>
<p>Username: <input type=”text” name=”username” /></p>
<p>Character Name: <input type=”text” name=”character” /></p>
<p>Password: <input type=”password” name=”pass” /></p>
<p>Confirm Password: <input type=”password” name=”confirm” /></p>
<p><input type=”submit” value=”Log In” /></p>
</form>
<?php
}
require (‘templates/template2.html’);
ob_end_flush();
?>
Section 2 “loggedin.php”:
[code=php]
<?php
ob_start();
require (‘templates/template1.html’);
session_start();
$username = $_POST[‘username’];
$password = $_POST[‘pass’];
$confirm = $_POST[‘confirm’];
$character = $_POST[‘character’];
if ($password != $confirm) {
print (“<p>Passwords did not match. Please go back and try again. P.S. You don’t have javascript enabled.</p>”);
} else {
switch ($username) {
case “Stevos”:
switch ($password) {
case “sarahatamian”:
$_SESSION[‘uhusername’] = $username;
$_SESSION[‘uhpassword’] = $password;
$_SESSION[‘uhcharacter’] = $character;
print (“<p>Thank you. You are now logged in as ” . $_SESSION[‘username’] . “.</p>”);
header (‘Location: index.php’);
exit();
break;
default:
print (“<p>That password does not match the username you entered.</p>”);
break;
}
break;
case “Rhalyth”:
switch ($password) {
case “leeroy666”:
$_SESSION[‘uhusername’] = $username;
$_SESSION[‘uhpassword’] = $password;
$_SESSION[‘uhcharacter’] = $character;
print (“<p>Thank you. You are now logged in as ” . $_SESSION[‘username’] . “.</p>”);
header (‘Location: index.php’);
exit();
break;
default:
print (“<p>That password does not match the username you entered.</p>”);
break;
}
break;
case “Gayle”:
switch ($password) {
case “sarahatamian”:
$_SESSION[‘uhusername’] = $username;
$_SESSION[‘uhpassword’] = $password;
$_SESSION[‘uhcharacter’] = $character;
print (“<p>Thank you. You are now logged in as ” . $_SESSION[‘username’] . “.</p>”);
header (‘Location: index.php’);
exit();
break;
default:
print (“<p>That password does not match the username you entered.</p>”);
break;
}
default:
print (“<p>We have no record of that username. If you are not an admin, you will not be able to sign in here.</p>”);
break;
}
}
require (‘templates/template2.html’);
ob_end_flush();
?>
Section 1 works, Section 2 does not.
If you need more information, please ask. I put a lot in the first try, but now I’m just annoyed.
Sorry if it’s just a stupid and obvious syntax error.