Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2. $error=''; //Variable to Store error message;
  3. if(isset($_POST['submit'])){
  4. if(empty($_POST['user']) || empty($_POST['pass'])){
  5. $error = "Username or Password is Invalid";
  6. }
  7. else
  8. {
  9. //Define $user and $pass
  10. $user=$_POST['user'];
  11. $pass=$_POST['pass'];
  12.  
  13. //Establishing Connection with server by passing server_name, user_id and pass as a patameter
  14. $conn = mysqli_connect("localhost", "root", "");
  15. //Selecting Database
  16. $db = mysqli_select_db($conn, "test");
  17. //sql query to fetch information of registerd user and finds user match.
  18. $query = mysqli_query($conn, "SELECT * FROM userpass WHERE pass='$pass' AND user='$user'");
  19.  
  20. $rows = mysqli_num_rows($query);
  21. if($rows == 1){
  22. header("Location: welcome.php"); // Redirecting to other page
  23. }
  24. else
  25. {
  26. $error = "Username of Password is Invalid";
  27. }
  28. mysqli_close($conn); // Closing connection
  29. }
  30. }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement