Viewing file: conn.php (1.1 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php /* $con make a connection with database */ $con=mysql_connect("hostname","username","password"); //select database mysql_select_db("databaseame"); /* Below two commands will store the data in variables came from form input */ $username=$_POST['username']; $password=$_POST['password']; /* below two commands are sql injection which stops extra characters as input */ $user=mysql_real_escape_string($username); $pass=mysql_real_escape_string($password); $query=mysql_query("SELECT * FROM login where username='$user' AND password='$pass' "); $count=mysql_num_rows($query); if($count==1) /* $count checks if username and password are in same row */ { echo "Login Successful"; $hour = time() + 3600; /* $hour sets cookie storage time for 1 hour */ /* setcookie() function sets cookie after login */ setcookie("username", $username, $hour); setcookie("password", $password, $hour); header("location: redirecting page link"); /* header() function redirect user to members page */ } else { echo "Username or password is incorrect"; } ?>
|