Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con = mysql_connect("localhost","root","");
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db("users", $con) or die("Can't select db.");
- if (isset($_POST['username']) && isset($_POST['password')) {
- if (($_POST['username'] == $user) && ($_POST['password'] == $pass)) {
- if (isset($_POST['rememberme'])) {
- /* Set cookie to last 1 year */
- setcookie('username', $_POST['username'], time()+60*60*24*365
- setcookie('password', md5($_POST['password']), time()+60*60*24*365
- } else {
- /* Cookie expires when browser closes */
- setcookie('username', $_POST['username'], false
- setcookie('password', md5($_POST['password']), false
- }
- header('Location: login.php');
- } else {
- echo 'Username/Password Invalid';
- }
- } else {
- echo 'You must supply a username and password.';
- }
- ?>
- <!DOCTYPE html>
- <html>
- <body>
- <form action="login.php" method="POST">
- Username: <input type="text" name="username"><br>
- Password: <input type="password" name="password"><br />
- <input type="submit" value="Login."></form> <br />
- </body>
- </html>
Add Comment
Please, Sign In to add comment