Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Test Php Page</title>
- </head>
- <form action="welcome.php" method="post">
- User: <input type="text" name="user" />
- Password: <input type="password" name="password" />
- <input type="submit" />
- </form>
- </form>
- </body>
- </html>
- Welcome.php
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title></title>
- </head>
- <?php
- $con = mysql_connect("localhost","root","0000");
- if (!$con)
- {
- die('Count not connect: ' . mysql_error());
- } else
- {
- mysql_select_db("phptest", $con);
- $sql = "CREATE TABLE IF NOT EXISTS users
- (
- personID int NOT NULL AUTO_INCREMENT,
- PRIMARY KEY(personID),
- Username varchar(15),
- Password varchar(15)
- )";
- mysql_query($sql,$con);
- $user = $_POST["user"];
- $pass = $_POST["password"];
- $sql2 = "SELECT * FROM users
- WHERE Username='$user'
- ";
- $result = mysql_query($sql2,$con);
- if($result === FALSE) {
- die(mysql_error());
- } else
- {
- if(mysql_fetch_array($sql2) === FALSE) {
- die(mysql_error());
- } else
- $row = mysql_fetch_array($sql2);
- if ($row['Password'][0] == $pass)
- {
- echo "You Have Logged in correctly";
- } else
- {
- echo "User and Password do not match";
- }
- }
- }
- ?>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement