Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title> Log-in </title>
- </head>
- <body>
- <form action="login.php" method="POST">
- Username: <input type="text" name=username">
- Password: <input type="password" name="password">
- <input type="submit" name="login" value="Login">
- </form>
- <?php
- if(isset($_POST['username']) && isset($_POST['login'])){
- $un = $_POST['username'];
- }
- if(isset($_POST['password']) && isset($_POST['login'])){
- $pass = $_POST['password'];
- }
- $db = mysql_connect("127.0.0.1:3306", "root" , "Iaml33+lol");
- if(!$db) {
- die("Error connecting to database: " . mysql_error());
- }
- $db_used = mysql_select_db("login", $db);
- if(!$db_used){
- die("Could not select database: " . mysql_error());
- }
- $user_name = mysql_real_escape_string($un);
- $password = mysql_real_escape_string($pass);
- $query = "SELECT * FROM details WHERE un='$user_name' AND pwd='$password'";
- $check = mysql_query($query);
- $check_rows = mysql_num_rows($check);
- if(isset($_POST['login']) && $check_rows == 1){
- echo "Login was successful, redirecting now";
- }
- else{
- echo "Login failed, please ensure you use the right username and password";
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment