Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- ?>
- <html>
- <head>
- <title>Login</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <h1><img src="TBS.png" alt="Logo"/>
- <br>
- Login Page
- </h1>
- <ul id="menubar">
- <li><a href="homePage.php">Home</a></li>
- <li><a href="aboutus.html">About Us</a></li>
- <li><a href="contactus.html">Contact Us</a></li>
- <li><a href="loginPage.php">Login</a></li>
- </ul>
- <div>
- <br>
- <br>
- <br>
- <br>
- <ul id="textarea">
- Username:<br><input type="text" name="username"><br>
- Password:<br><input type="password" name="password"><br>
- </ul>
- <ul id="buttons">
- <input name="Login" type="submit" value="Login">
- <button><a href="homePage.php">Cancel</a></button>
- </ul>
- <?php
- if ($_POST['Login']) {
- include_once("database.php");
- $username = strip_tags($_POST['username']);
- $password = strip_tags($_POST['password']);
- $username = stripcslashes($username);
- $password = stripcslashes($password);
- $username = mysqli_real_escape_string($username);
- $password = mysqli_real_escape_string($password);
- $sql = "SELECT * FROM user WHERE username='$username'";
- $query = mysqli_query($db, $sql);
- $row = mysqli_fetch_array($query);
- $id = $row['id'];
- $db_password = $row['password'];
- if ($password == $db_password) {
- $_SESSION['username'] = $username;
- $_SESSION['id'] = $id;
- header("Location: homePage.php");
- } else {
- echo "you entered the wrong password";
- }
- }
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement