Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- if(isset($_POST['username'])){
- $dbHost = "localhost"; //Location Of Database usually its localhost
- $dbUser = "root"; //Database User Name
- $dbPass = ""; //Database Password
- $dbDatabase = "game"; //Database Name
- $email = 'Rdogg999@hotmail.com';
- $db = mysql_connect($dbHost,$dbUser,$dbPass)or die("Error connecting to database.");
- mysql_select_db($dbDatabase, $db)or die("Couldn't select the database.");
- $pass = md5($_POST['password']);
- $sql= mysql_query("SELECT * FROM users WHERE username={$_POST['username']} AND password={$pass}");
- if($sql){
- $row = mysql_fetch_array($sql);
- if($row){ //If there is a row start a session with values, then transfer to the users page
- session_start();
- $_SESSION['username'] = $row['username'];
- $_SESSION['id'] = $row['id'];
- $_SESSION['logged'] = TRUE;
- header("Location: index.php");
- }else{ //If there isn't a row return the user to a login page
- header("Location: login.php");
- exit;
- }
- }else{
- // There was some sort of error, check your email
- mail($email, 'MySQL Error', mysql_error());
- header("Location: login.php");
- exit;
- }
- }else{ //If the form button wasn't submitted go to the index page, or login page
- header("Location: index.php");
- exit;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement