Advertisement
Guest User

Untitled

a guest
May 7th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. </head>
  5. <body>
  6.  
  7.  
  8. <?php
  9. $host="localhost";
  10. $username="vaolabsfi_stud";
  11. $password="fVC97!g0";
  12. $db_name="vaolabsfi_digitala1";
  13. $tbl_name="accountInfo";
  14.  
  15.  
  16.  
  17. // Connect to server and select databse.
  18. mysql_connect("$host", "$username", "$password") or die(mysql_error());
  19. echo "Connected to MySQL<br />";
  20. mysql_select_db("$db_name") or die(mysql_error());
  21. echo "Connected to Database<br />";
  22.  
  23. // Check $username and $password
  24.  
  25.  
  26.  
  27. // Define $username and $password
  28. $username=$_POST['username'];
  29. $pass=($_POST['pass']);
  30.  
  31.  
  32. // To protect MySQL injection
  33. $username = stripslashes($username);
  34. $password = stripslashes($password);
  35. $username = mysql_real_escape_string($username);
  36. $password = mysql_real_escape_string($password);
  37.  
  38. $sql="SELECT * FROM accountInfo WHERE username='$username' and pass='$pass'";
  39. $result=mysql_query($sql);
  40.  
  41. // Mysql_num_row is counting table row
  42. $count=mysql_num_rows($result);
  43. // If result matched $username and $password, table row must be 1 row
  44. if ($count==1) {
  45. echo "Success! $count";
  46. session_start();
  47.  
  48.  
  49. $sql2="SELECT email WHERE username = "' . $username .'" AND pass="' . $pass .'"
  50.  
  51.  
  52.  
  53. } else {
  54. echo "Unsuccessful! $count";
  55.  
  56.  
  57. }
  58.  
  59. ?>
  60.  
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement