Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include('includes/header.php');?>
- <?php
- require_once('includes/mysqli_connect.php');
- if(isset($_POST['login']))
- {
- $username = $_POST['txtUsername'];
- $password = $_POST['txtPassword'];
- $query = "select * from accounts where (userName = '$username' and userPassword = SHA('$password'))";
- $result = mysqli_query($dbc, $query);
- $num = mysqli_num_rows($result);
- $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
- $_SESSION['user_name'] = $row['userName'];
- $name = $row['userName'];
- setcookie('recordsmember', $name, time()+60*60*2);
- if($num > 0)
- {
- header('Location: home.php');
- }
- else
- {
- echo "Unknown user or incorrect password!";
- }
- }
- ?>
- <h1>login</h1>
- <form action="login.php" method="post">
- <fieldset>
- <input type="text" name="txtUsername" placeholder="enter a username"/><br/>
- <input type="password" name="txtPassword" placeholder="enter a password"/><br/>
- <input type="submit" name="login" value="login"/>
- </fieldset>
- </form>
- <?php include('includes/footer.html');?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement