eventually this program will compare the email and password entered from a mysql db. as of right now it just takes the email from the text field and uses that in the cookie.
when i return to the signin page if the cookie is set it
should just prompt the user for their password with just a password text line. for someone reason this does not happen. any help is appreciated in advance.
Thank You
<?php
session_start();
$info = isset($COOKIE['em_email'])?$COOKIE['em_email'] : NULL;
if(is_null($info)) //user needs to login
{
if(isset($_POST['email'])) //upon post set cookie
{
$_SESSION['email']=$_POST['email'];
setcookie("em_email", $_SESSION['email'], time()+600);
}
else
{
mainPage(); //show main page first time through
}
}
else
{
passOnly(); //user is revisiting page
}
function mainPage()
{
?>
<html>
<head>
<title>GradeGrinder Signin</title>
<LINK href="special.css" rel="stylesheet" type="text/css">
</head>
<body>
<h2>Please sign-in below</h2>
<form name="login" action="Signin.php" method=Post onSubmit="blanks()">
<h4>Email: </h4>
<input type="text" name="email" size="30" maxlength="30">
<h4>Password: </h4>
<input type="password" name="pass" size="30" maxlength="30">
<h6>Forgot Password <input type="checkbox" name="forgotpassword"></h6>
<h6>(Your password will be emailed to you)</h6>
<input type="submit" value="Next">
</form></body>
</html>
<?php
}
function passOnly()
{
?>
<html>
<head>
<title>GradeGrinder Signin</title>
<LINK href="special.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
echo "<h2>Welcome back $info</h2>"
?>
<form name="visitor" action="Signin.php" method=Post onSubmit="passBlank()">
<h4>Password: </h4>
<input type="password" name="pw" size="30" maxlength="30">
<input type="submit" value="Next">
</form></body>
</html>
<?php
}
?>
<script type = "text/javascript">
function blanks()
{
if(login.email.value=="") //check email field first if blank we cant do anything else
{
alert ("Email is BLANK please try again.");
event.returnValue=false;
}
else if(login.pass.value==""&&login.forgotpassword.checked==false) //if no pw, then check if forgot pw checked
{
alert("Password is BLANK please try again.");
event.returnValue=false;
}
else if(login.email.value!=""&&login.forgotpassword.checked==true) //if email entered and forgot pw checked send email
{
alert("Please check email for your password!");
event.returnValue=false;
}
else
{
location.replace("GradeGrinder.php");
alert("You are now being signed in to Grade Grinder!");
}
}
function passBlank()
{
if(visitor.pw.value=="")
{
alert("Enter your password to continue!");
event.returnValue=false;
}
else
{
location.replace("GradeGrinder.php");
alert("You are now being signed in to Grade Grinder!");
}
}
</script>