Created
October 15, 2012 16:36
-
-
Save optikalefx/3893479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// catch form submit | |
if(isset($_POST['submit'])) { | |
// make it safe for mysql | |
$name = mysql_real_escape_string($_POST['name']); | |
$password = mysql_real_escape_string($_POST['password']); | |
// if we found a match | |
if($password == "google") { | |
//set this user to the session and go the index | |
session_start(); | |
$_SESSION['user'] = array( | |
"id"=>"1", | |
"first_name"=>"lois", | |
"last_name"=>"griffen" | |
); | |
// go to index | |
header("Location: index.php"); | |
exit(); | |
// if not, say wrong login | |
} else { | |
echo "<div class='error'>Incorrect Login</div>"; | |
} | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-latest.min.js"></script> | |
<style type="text/css"> | |
body { | |
font-family:verdana; | |
font-size:11px; | |
} | |
.login { | |
width:500px; | |
margin:150px auto; | |
padding:40px; | |
border:1px solid #DDD; | |
} | |
.login input { | |
font-size:10px; | |
border:1px solid #ccc; | |
font-weight:normal; | |
display:block; | |
padding:6px; | |
margin-top:7px; | |
width:150px; | |
} | |
.login label { | |
font-size:10px; | |
color:#333; | |
font-weight:bold; | |
display:block; | |
margin-top:7px; | |
} | |
.login [type="submit"] { | |
background:#333; | |
font-size:10px; | |
font-weight:bold; | |
margin-top:20px; | |
color:white; | |
padding:10px; | |
cursor:pointer; | |
width:50px; | |
} | |
.error { | |
background:red; | |
color:white; | |
padding:15px; | |
margin:20px; | |
width:150px; | |
border:1px solid #CCC; | |
font-size:11px; | |
font-weight:bold; | |
} | |
</style> | |
</head> | |
<body> | |
<form class="login" action="login.php" method="post"> | |
<label>FirstName</label> | |
<input name="name" type="text"/> | |
<label>Password</label> | |
<input name="password" type="password"/> | |
<input type="submit" name="submit" value="Login"/> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment