Guest User

Untitled

a guest
Jan 7th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <form action="Access.php" method="POST">
  6. <input type="text" name="Username" placeholder="Insert your username" required></input>
  7. <input type="password" name="Userpassword" placeholder="Insert your password" required></input>
  8. <input type="submit" value="Log in" />
  9. </form>
  10. </body>
  11. </html>
  12.  
  13. <html>
  14. <head>
  15. </head>
  16. <body>
  17. <?php
  18. $Username=$_POST['Username'];
  19. $Userpassword=$_POST['Userpassword'];
  20. $servername="localhost";
  21. $dbUsername="username"; //<-- Here, substitude username with the username you use to log into your database
  22. $dbPassword="password"; //<-- Same of $dbUsername
  23. $databasename = "my_database"; //<-- substitude with your database name
  24.  
  25. $Username = stripcslashes($Username);
  26. $Userpassword= stripcslashes($Userpassword);
  27. $Username=mysql_real_escape_string($Username);
  28. $Userpassword=mysql_real_escape_string($Userpassword);
  29.  
  30. mysql_connect($servername, $dbUsername, $dbPassword);
  31. mysql_select_db=($databasename);
  32.  
  33. $result=mysql_query("SELECT * FROM users WHERE Username='$Username' AND Userpassword='$Userpassword'") or die ("Damn, something didn't work! Error: ".mysql_error());
  34.  
  35. $row = mysql_fetch_array($result);
  36.  
  37. if ($row['Username'] == $Username && $row['Userpassword'] == $Userpassword){
  38. echo "Log in success, you'll be redirect into your profile page
  39. <meta http-equiv="refresh" content="8;URL=UserProfilePage.php?ID_User=".$row['ID_User'].""/>";
  40. } else {
  41. echo "The username $Username doesn't exist or you used a wrong password";
  42. }
  43. ?>
  44. </body>
  45. </html>
Add Comment
Please, Sign In to add comment