Advertisement
Guest User

Untitled

a guest
May 10th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <html>
  2. <head></head>
  3. <body>
  4. <?php
  5.  
  6. // Inialize session
  7. session_start();
  8.  
  9. // Include database connection settings
  10. $hostname = "localhost";
  11. $username = "root";
  12. $password = "Asimov";
  13. $db_name = "course";
  14. $con = mysql_connect($hostname,$username,$password);
  15. if (!$con)
  16. {
  17. die('Could not connect: ' . mysql_error());
  18. }
  19.  
  20. mysql_select_db($db_name, $con);
  21. // Retrieve username and password from database according to user's input
  22. $login = mysql_query("SELECT * FROM student WHERE (loginid = '" . mysql_real_escape_string($_POST['loginid']) . "') and (pass = '" . mysql_real_escape_string($_POST['pass']) . "')");
  23.  
  24.  
  25.  
  26.  
  27. // Check username and password match
  28. if (mysql_num_rows($login) == 1) {
  29. // Set username session variable
  30. $_SESSION['loginid'] = $_POST['loginid'];
  31. $_SESSION['pass'] = $_POST['pass'];
  32. // Jump to secured page
  33. header('Location: detail.php');
  34. }
  35. else {
  36. // Jump to login page
  37.  
  38. header('Location: home1.php');
  39.  
  40. }
  41.  
  42. ?>
  43. </body>
  44. <html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement