Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action ="" method="post">
- User Name:<br/>
- <input type='text' name='username' />
- <br/><br/>
- Password:<br/>
- <input type='password' name='password' />
- <br/><br/>
- <input type='submit' name='submit' value='login'>
- </form>
- <?php
- if(isset($_POST['submit'])){
- $username = $_POST['username'];
- $password = md5($_POST['password']);
- $stmt = $con->prepare("SELECT username, password FROM users WHERE username=? AND password=? LIMIT 1");
- $stmt->bind_param('ss', $username, $password);
- $stmt->execute();
- $stmt->bind_result($username, $password);
- $stmt->store_result();
- if($stmt->num_rows == 1) //To check if the row exists
- {
- while($stmt->fetch()) //fetching the contents of the row
- {$_SESSION['Logged'] = 1;
- $_SESSION['username'] = $username;
- echo 'Success!';
- exit();
- }
- }
- else {
- echo "INVALID USERNAME/PASSWORD Combination!";
- }
- $stmt->close();
- }
- else
- {
- }
- $con->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement