Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <form action="login.php" method="post">
- Username: <input type="text" name="username"><p>
- Password: <input type="password" name="password"><p>
- <input type="submit" value="Log in!" >
- </form>
- <?php
- session_start();
- $username = $_POST['username'];
- $password = $_POST['password'];
- if ($username&&$password)
- {
- $connect = mysql_connect("localhost", "root", "") or die("Couldn't connect to the database!");
- mysql_select_db("login") or die("Couldn't find database");
- $query = mysql_query("SELECT * FROM users WHERE username='$username'");
- $numrows = mysql_num_rows($query);
- if ($numrows!==0)
- {
- while($row = mysql_fetch_assoc($query))
- {
- $dbusername = $row['username'];
- $dbpassword = $row['password']; # code...
- }
- if ($username==$dbusername&&$password==$dbpassword)
- {
- echo "You are logged in!";#
- @$_SESSION['usernme'] = $username;
- }
- else
- echo "Your password is incorrect!";
- # code...
- }
- else
- die("That user doesn't exists!");
- }
- else
- die("Please enter a username and password!")
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement