Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('./global.php');
- $title = "Login";
- $error = "";
- $succes = "";
- if(isset($_POST['login'])) {
- $username = mysql_real_escape_string($_POST['username']);
- $password = $_POST['password'];
- if(trim($username) == "" or trim($password) == "") {
- $error = "<div class=\"notification error closeable\"><p><b>Error:</b> Please make sure you enter a username & a password to login.</p></div>";
- } else {
- $result = mysql_query("SELECT * FROM users WHERE user_name = '".$username."'") or trigger_error(mysql_error());
- if(!$row = mysql_fetch_assoc($result)) {
- $error = "<div class\"notification error closeable\"><p>That username was not found.</p></div>"; exit();
- } elseif ($row['password'] != md5($password)) {
- $error = "<div class=\"notification error closeable\"><b>Error:</b> That password was incorrect."; exit();
- } else {
- $_SESSION['user_id'] = $row['user_id'];
- $_SESSION['user_name'] = $row['user_name'];
- $_SESSION['user_email'] = $row['email'];
- $_SESSION['firstname'] = $row['firstname'];
- $_SESSION['middlename'] = $row['middlename'];
- $_SESSION['lastname'] = $row['lastname'];
- $succes = "<div class=\"notification success closeable\"><b>Success:</b> <p>Thank you for registering!</p>";exit();
- }
- }
- }
- // Start VARs
- $template->vars(array(
- 'TITLE' => $title,
- 'ERROR' => $error,
- ));
- $template->display('Login page', 'login_body.html', '');
Add Comment
Please, Sign In to add comment