Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //setting variables for connecting to database
- $host = 'localhost';
- $username = 'root';
- $password = '';
- $db = 'aquamandb';
- date_default_timezone_set('America/Chicago');
- //connecting to the database
- $connect = new mysqli($host,$username, $password, $db) or die("Unable to connect");
- //getting the username, and password for sanitizing
- $_US_username = $_POST['username'];
- $_US_password = $_POST['password'];
- //sanitize the variable to remove SQL statements that could drop the database potentially.
- $username = mysql_real_escape_string($_US_username);
- $password = mysql_real_escape_string($_US_password);
- $sql = "SELECT * FROM user WHERE username = '$username' AND password = '$password'";
- $result = mysqli_query($sql);
- $numrows = mysql_num_rows($result);
- if($numrows > 0)
- {
- while($row = mysqli_fetch_assoc($result))
- {
- echo "id: " . $row["userID"]. " - UserName: " . $row["username"]. " " . $row["password"]. " - Type: " . $row["type"]. "<br>";
- }
- }
- else
- {
- echo "username does not match!";
- }
- ?>
- <!DOCTYPE html><!-- login.html -->
- <?php include "../php/action_page.php"; ?>
- <html>
- <head lang="en">
- <meta charset="UTF-8">
- <title>Login</title>
- <link href="css/login_2.css" rel="stylesheet">
- </head>
- <body>
- <div class="login-form">
- <form id = "login_form" action="php/action_page.php" method ="POST">
- <h1> Login </h1>
- <input type='hidden' name='submitted' id='submitted' value='1' />
- <div class="form">
- <input type ="text" name='username' class="credentials-form" placeholder="Username" id="Username">
- </div>
- <div class="form data">
- <input type ="password" name='password' class="credentials-form" placeholder="Password" id="Password">
- </div>
- <input type='submit' name='Submit' value='Login' class='button'/>
- <button type="button" class="button" id="acc" onclick="location.href='createAccount.html';"><span>Create Account</span></button>
- </form>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement