Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- -- To Do --
- * Change values in the connection
- * Change field & table names in the query
- */
- session_start();
- $db = new mysqli("localhost", "d290986_chav", "courtney1232008", "d290986_mywebsite");
- if( isset($_POST) ) {
- /*
- -- To Do --
- * Encrypt password
- */
- $exist = $db->query("SELECT `userid`,`username` FROM `login` WHERE `username`='{$_POST['username']}' AND `password`='{$_POST['pass']}'");
- if( $exist->num_rows ) {
- $r = $exist->fetch_array(MYSQLI_ASSOC);
- $_SESSION['loggedin'] = 1;
- $_SESSION['user'] = $r['user'];
- echo 'You\'ve loggedin!' $r['username'] . PHP_EOL;
- } else {
- echo 'Can\'t find you!' . PHP_EOL;
- }
- }
- ?>
- <form action="" method="post">
- Username <input type="text" name="username" length="5" size="5" maxlength="20" /> <br />
- Password <input type="password" name="pass" length="5" size="5" maxlength="25" /> <br />
- <input type="submit" value="login" />
- </form>
Advertisement
Add Comment
Please, Sign In to add comment