Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author Jason
- * @copyright 2010
- */
- $username = $_POST['username'];
- $password = $_POST['password'];
- if ($username&&$password) {
- $connect = mysql_connect("localhost","root","jason") or die("Cannot connect to database!");
- mysql_select_db("usersystem") or die("Cannot connect to database!");
- $query = mysql_query("SELECT * FROM users WHERE username='$username'");
- $numrows = mysql_num_rows($query);
- if (numrows!=0) {
- while ($r = mysql_fetch_assoc($query)) {
- $dbusername = $r['username'];
- $dbpassword = $r['password'];
- }
- if ($username==$dbusername&&$password==$dbpassword) {
- echo "You're in!";
- } else
- echo "Incorrect Password";
- } else
- die("Username doesn't exist!");
- } else
- die("Please enter a username and password.");
- ?>
- <html>
- <form action='index.php' method='POST'>
- Username: <input type="text" name="username"/><br />
- Password: <input type="password" name="password"/><br />
- <input type="submit" value="Log in"/>
- </form>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement