Advertisement
Guest User

Untitled

a guest
May 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  3. if (empty($_POST['username'])) {
  4. $error = "Username is empty";
  5. }
  6. else
  7. {
  8. // Define $username and $password
  9. $username=$_POST['username'];
  10. // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  11. $connection = mysql_connect("server°name", "user", "pass");
  12. $username = $username;
  13. // Selecting Database
  14. $db = mysql_select_db("u843753740_test", $connection);
  15. // SQL query to fetch information of registerd users and finds user match.
  16.  
  17. $query = mysql_query("SELECT * FROM login WHERE username='$username'", $connection);
  18. if ($rows == true)
  19. $rows = mysql_num_rows($query);
  20. if(! $query ) {
  21. die('Could not request data: ' . mysql_error());
  22. }
  23. if ($rows > 1)
  24. echo "SQL Injection succesfully completed! <br/> " .$rows;
  25. else
  26. echo "SQL Injection failed! <br/> " .$rows;
  27.  
  28. $usersArray = array(); // make a new array to hold all your data
  29.  
  30.  
  31. $index = 0;
  32. while($row = mysql_fetch_assoc($query)){ // loop to store the data in an associative array.
  33. $usersArray[$index] = $row;
  34. echo "<br/> array: " .$usersArray[$index]['username'];
  35. $index++;
  36. }
  37.  
  38. mysql_close($connection); // Closing Connection
  39. }
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement