Advertisement
Guest User

Untitled

a guest
Sep 29th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. // Get data from form
  5. $username = $_POST['username'];
  6. $password = $_POST['password'];
  7.  
  8. // Connect to the database
  9. $dbhost = 'localhost'; // Database host
  10. $dbuser = 'dbusername'; //Database username
  11. $dbpass = 'dbpassword'; //Database password
  12. $dbname = 'dbname'; //database name
  13.  
  14. // Run the data connection
  15. $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
  16.  
  17. // Select which database you want to use
  18. mysql_select_db($dbname, $conn);
  19.  
  20. // Look in database to see if there are any account with the chosen username and password
  21. $sql_uname_check = "SELECT * FROM people WHERE username='$username' AND password='$password';";
  22. // So this says have a look and see if there is an account in the people table with the selected username AND password
  23.  
  24. // Run the query and put the results in a variable
  25. $result_name_check = mysql_query($sql_uname_check);
  26.  
  27. // Count how many users were returned
  28. $peepsfound = mysql_num_rows($result_name_check);
  29.  
  30.  
  31. // there were 0 users found ( < 1)
  32. if ($peepsfound < 1) {
  33.  
  34.     // Error not found
  35.     $error = "User $uname not found.";
  36.  
  37. //If there was a user found
  38. } else {
  39.        
  40.         //Add their details to the session for use later
  41.         $_SESSION['unamename'] = $uname;
  42.         $_SESSION['encryptcode'] = $code;
  43.        
  44.     }
  45. }
  46.  
  47. /* End of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement