Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <?php
  2.  
  3. echo("Hello Lewis");
  4.  
  5. session_start();
  6.  
  7. //convert the field values to simple variables
  8.  
  9. //add slashes to the username and md5() the password
  10. $user = addslashes($_POST['username']);
  11. $pass = md5($_POST['password']);
  12.  
  13. echo $pass;
  14. //set the database connection variables
  15.  
  16. $dbHost = "localhost";
  17. $dbUser = "root";
  18. $dbPass = "pqqmsb";
  19. $dbDatabase = "danpilch";
  20.  
  21. //connect to the database
  22.  
  23. $db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
  24.  
  25. mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
  26.  
  27. $result = mysql_query("select * from registration where username='$user' AND password='$pass'", $db);
  28.  
  29. //check that at least one row was returned
  30.  
  31. $rowCheck = mysql_num_rows($result);
  32. $row = mysql_fetch_array($result);
  33. if($rowCheck > 0){
  34.  
  35.   //start the session and register a variable
  36.  
  37.     $_SESSION['username']= $row['username'];
  38.     // redirect to home page
  39.     header("location:usersettings.php?username=" . $row['username']);
  40.  
  41.  
  42.  }
  43.  else {
  44.  
  45.   header("location:incorrect-password.php");
  46.   }
  47.  
  48.   ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement