Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- // Establish a connection to the database
- $con = mysqli_connect("localhost", "cairil_php", "phpsql");
- // Check if there were any issues connecting to the database
- if ( mysqli_connect_errno() != 0)
- {
- die("An error occurred trying to establish a connection: " .mysqli_connect_error());
- }
- // define username + password
- $user = mysql_real_escape_string($_POST['user']);
- $pass = mysql_real_escape_string($_POST['pass']);
- // Select the database to work with.
- $db = mysqli_select_db ($con , "cairil_php");
- $query = mysql_query("SELECT * FROM customer WHERE `cust_password`='$pass', `cust_email`='$pass' LIMIT 0,1");
- // Run the query using the connection established earlier and assign the results to a results object.
- $rs = mysqli_query ($con, $query);
- // Check if password/user failed
- if ( !$rs)
- {
- if ($_SESSION['counter'] > 3)
- {
- $_SESSION['counter']++;
- echo "You have failed me again Starscream.";
- header("Location: /week4/2214_login.php");
- }
- else {
- header("Location: /week4/2214_fail.php");
- }
- }
- else
- {
- $_SESSION['user'] = $user;
- $_SESSION['pass'] = $pass;
- header("Location: /2214_welcome.php");
- }
- // Close the connection
- mysqli_close($con);
- ?>
- <html>
- <head>
- <title> 2214_LoginAction.php</title>
- </head>
- <body bgcolor="#bbccaa">
- <br/><br/><br/>
- <center>
- <h3><?php echo($result); ?></h3>
- <br/>
- <a href="2214_login.php">Back to the Login Page</a>
- </center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement