Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2. $myServer = "localhost";
  3. $myUser = "myuser";
  4. $myPass = "password";
  5. $myDB = "testdb";
  6.  
  7. //connection to the database
  8. $dbhandle = mysql_connect($myServer, $myUser, $myPass)
  9. or die("Couldn't connect to SQL Server on $myServer");
  10.  
  11. //select a database to work with
  12. $selected = mysql_select_db($myDB, $dbhandle)
  13. or die("Couldn't open database $myDB");
  14.  
  15. // The response variable
  16. $res = "res=KO";
  17.  
  18. // Check incoming data
  19. if ($_POST['name'] != "" && $_POST['pass'] != "") {
  20.  
  21. // Retrieve all rows from the "user_name" and "password" columns from the "account_info" table
  22. $result = mysql_query("SELECT user_name, password FROM account_info")
  23. or die(mysql_error());
  24.  
  25. //create a loop that continues until each row is called
  26. while($row = mysql_fetch_array($result)) {
  27.  
  28. //check if client user name/password is the same as the row from database
  29. if ($_POST['name'] == $row['user_name'] && $_POST['pass'] == $row['password']) {
  30.  
  31. // If they match, Ok, user found
  32. $res = "res=OK";
  33. break;
  34. }
  35.  
  36. }
  37.  
  38. }
  39.  
  40. print $res;
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement