Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- </head>
- <body>
- <form action="Access.php" method="POST">
- <input type="text" name="Username" placeholder="Insert your username" required></input>
- <input type="password" name="Userpassword" placeholder="Insert your password" required></input>
- <input type="submit" value="Log in" />
- </form>
- </body>
- </html>
- <html>
- <head>
- </head>
- <body>
- <?php
- $Username=$_POST['Username'];
- $Userpassword=$_POST['Userpassword'];
- $servername="localhost";
- $dbUsername="username"; //<-- Here, substitude username with the username you use to log into your database
- $dbPassword="password"; //<-- Same of $dbUsername
- $databasename = "my_database"; //<-- substitude with your database name
- $Username = stripcslashes($Username);
- $Userpassword= stripcslashes($Userpassword);
- $Username=mysql_real_escape_string($Username);
- $Userpassword=mysql_real_escape_string($Userpassword);
- mysql_connect($servername, $dbUsername, $dbPassword);
- mysql_select_db=($databasename);
- $result=mysql_query("SELECT * FROM users WHERE Username='$Username' AND Userpassword='$Userpassword'") or die ("Damn, something didn't work! Error: ".mysql_error());
- $row = mysql_fetch_array($result);
- if ($row['Username'] == $Username && $row['Userpassword'] == $Userpassword){
- echo "Log in success, you'll be redirect into your profile page
- <meta http-equiv="refresh" content="8;URL=UserProfilePage.php?ID_User=".$row['ID_User'].""/>";
- } else {
- echo "The username $Username doesn't exist or you used a wrong password";
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment