Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $username = $_POST['username'];
- $password = $_POST['password'];
- if ($username && $password)
- {
- $connect = mysql_connect("localhost", "root", "") or die("Couldn't connect!");
- mysql_select_db("phplogin") or die("Couldn't find the 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'];
- }
- if ($dbusername == $username && $password == $dbpassword)
- {
- echo "You're in! <a href='homepage.html'> Click</a> here to enter the homepage.";
- $_SESSION['username'] = $dbusername;
- }
- else
- die("Incorrect password!");
- }
- else
- die("User does not exist!");
- }
- else
- die("Please enter a username and password.");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement