Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $output='';
- if (isset($_POST['submit'])){
- $username = $_POST['username'];
- $password = $_POST['password'];
- if(empty($_POST['username']) || empty($_POST['password'])){
- $output = "Username or Password is Invalid";
- }
- else
- {
- //Connect with server
- $mysqli = NEW Mysqli ('localhost', 'root', '', 'accounts');
- $username = $mysqli->real_escape_string ($_POST['username']);
- $password = $mysqli->real_escape_string ($_POST['password']);
- //finds user match.
- $query = mysqli_query($mysqli, "SELECT * FROM users WHERE password= md5 ('$password') AND username='$username'");
- $rows = mysqli_num_rows($query);
- if($rows == 1){
- session_start();
- $_SESSION["user"] = $username;
- header('Location: profile.php'); //directing to other page
- }
- else{
- $output = "Username and Password did not match our records";
- }
- mysqli_close($mysqli); // Close connection
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement