Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <?php
  2. define('DB_HOST', 'cs2s');
  3. define('DB_NAME', 'marcussampson');
  4. define('DB_USER','marcus.sampson');
  5. define('DB_PASSWORD','compsci1');
  6.  
  7. $con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL server");
  8. $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL server");
  9.  
  10.  
  11.  
  12. function SignIn()
  13. {
  14. session_start();
  15. if(!empty($_POST['username']))
  16. {
  17. $query = mysql_query("SELECT * FROM Users where username = '$_POST[username]' AND password = '$_POST[password]'") or die(mysql_error());
  18. $row = mysql_fetch_array($query);
  19. if(!empty($row['username']) AND !empty($row['password']))
  20. {
  21. $_SESSION['username'] = $row['password'];
  22. echo "You have successfully logged in to the Yorkshire Air Museum database system.";
  23. echo "<script>setTimeout(\"location.href = 'database.html';\",1500);</script>";
  24. }
  25.  
  26. else
  27. {
  28. echo "Combination of username and password not found on the system, please try again.";
  29. echo "<script>setTimeout(\"location.href = 'index.html';\",1500);</script>";
  30. }
  31.  
  32. }
  33. }
  34. if(isset($_POST['submit']))
  35. {
  36. SignIn();
  37. }
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement