Advertisement
Guest User

Untitled

a guest
Sep 12th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2.  
  3. //this is for an example of an SQL select statement, creating a "preparation" for the SQL statement to be executed
  4. $select_userq = $link->prepare("SELECT * FROM login_user WHERE username = ? AND password = ?");
  5.  
  6. //next is we bind the parameters to make sure which variables are to be inserted in the question marks
  7. $select_userq->bind_param("ss",$username,$password); //first comma is i for integer or s for string, etc.
  8.  
  9. //this simply executes the prepared SQL statement
  10. $select_userq->execute();
  11.  
  12. //this passes the variables that is selected from the select statement
  13. $select_userq->bind_result($user_id, $username, $password, $name, $email, $account_type, $college, $profile, $reference);
  14.  
  15. //now we have created a list of the values passed
  16. echo $username . "<br>" . $password "<br><br>";
  17.  
  18. //count number of rows, count if username and password exists
  19. $if_exists = $select_userq->num_rows;
  20.  
  21. if($if_exists>0)
  22. {
  23. while($row = $select_userq->fetch()) //fetch
  24. {
  25. $user = $row['username'];
  26. $pass = $row['password'];
  27. echo "Uname:". $user;
  28. echo "Pass:" . $pass "<br>";
  29. }
  30. }
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement