Guest User

Untitled

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