Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2. session_start(); // Starting Session
  3. $error=''; // Variable To Store Error Message
  4. if (isset($_POST['submit'])) {
  5.  
  6. if (empty($_POST['username']) || empty($_POST['password'])) {
  7. $error = "Username or Password is invalid";
  8. }
  9. else
  10. {
  11. // Define $username and $password
  12. $username=$_POST['username'];
  13. $password=$_POST['password'];
  14.  
  15. $connection = mysqli_connect("localhost", "username", "password", "dbname");
  16.  
  17. $query = mysql_real_query("select * from login where password='$password' AND username='$username'", $connection);
  18. $rows = mysql_num_rows($query);
  19.  
  20. if ($rows == 1) {
  21. $_SESSION['login_user']=$username; // Initializing Session
  22. header("location: profile.php"); // Redirecting To Other Page
  23.  
  24. } else {
  25. $error = "Username or Password is invalid";
  26. }
  27.  
  28. mysql_close($connection); // Closing Connection
  29. }
  30. }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement