Advertisement
giraffeinatutu

2214_action

Aug 15th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. // Establish a connection to the database
  5. $con = mysqli_connect("localhost", "cairil_php", "phpsql");
  6.  
  7. // Check if there were any issues connecting to the database
  8. if ( mysqli_connect_errno() != 0)
  9. {
  10. die("An error occurred trying to establish a connection: " .mysqli_connect_error());
  11. }
  12.  
  13. // define username + password
  14. $user = mysql_real_escape_string($_POST['user']);
  15. $pass = mysql_real_escape_string($_POST['pass']);
  16.  
  17.  
  18. // Select the database to work with.
  19. $db = mysqli_select_db ($con , "cairil_php");
  20. $query = mysql_query("SELECT * FROM customer WHERE `cust_password`='$pass', `cust_email`='$pass' LIMIT 0,1");
  21.  
  22.  
  23. // Run the query using the connection established earlier and assign the results to a results object.
  24. $rs = mysqli_query ($con, $query);
  25.  
  26.  
  27. // Check if password/user failed
  28. if ( !$rs)
  29. {
  30.  
  31. if ($_SESSION['counter'] > 3)
  32. {
  33. $_SESSION['counter']++;
  34.  
  35. echo "You have failed me again Starscream.";
  36. header("Location: /week4/2214_login.php");
  37. }
  38. else {
  39. header("Location: /week4/2214_fail.php");
  40. }
  41. }
  42. else
  43. {
  44. $_SESSION['user'] = $user;
  45. $_SESSION['pass'] = $pass;
  46. header("Location: /2214_welcome.php");
  47. }
  48.  
  49. // Close the connection
  50. mysqli_close($con);
  51.  
  52. ?>
  53.  
  54. <html>
  55. <head>
  56. <title> 2214_LoginAction.php</title>
  57. </head>
  58. <body bgcolor="#bbccaa">
  59. <br/><br/><br/>
  60. <center>
  61. <h3><?php echo($result); ?></h3>
  62. <br/>
  63. <a href="2214_login.php">Back to the Login Page</a>
  64. </center>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement