Advertisement
Guest User

Untitled

a guest
Apr 15th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <?php
  2. session_start(); // Starting Session
  3. $error=''; // Variable To Store Error Message
  4. if (isset($_POST['submit'])) {
  5. if (empty($_POST['username']) || empty($_POST['password'])) {
  6. $error = "Username or Password is invalid";
  7. }
  8. else
  9. {
  10. // Define $username and $password
  11. $username=$_POST['username'];
  12. $password=$_POST['password'];
  13.     $password1=md5($password);
  14. // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  15. $connection = mysqli_connect("localhost", "xxxx", "xxxxx");
  16. // To protect MySQL injection for Security purpose
  17. $username = stripslashes($username);
  18. $password = stripslashes($password);
  19. $username = mysqli_real_escape_string($connection,$username);
  20. $password = mysqli_real_escape_string($connection,$password);
  21. // Selecting Database
  22. $db = mysqli_select_db($connection,"acehigh_1");
  23. // SQL query to fetch information of registerd users and finds user match.
  24. $query = mysqli_query($connection,"select * from vartotojai where v_slaptazodis='$password1' AND v_vardas='$username'" );
  25. $rows = mysqli_num_rows($query);
  26.    
  27. if ($rows == 1) {
  28. $_SESSION['login_user']= $username; // Initializing Session
  29.    
  30. header("location: profile.php"); // Redirecting To Other Page
  31. } else {
  32. $error = "Username or Password is invalid";
  33. }
  34. mysqli_close($connection); // Closing Connection
  35. }
  36. }
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement