Advertisement
Guest User

Untitled

a guest
May 15th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. $connect = new mysqli("localhost", "root", "gasamul", "portfolio");
  2.  
  3. /* CHECK CONNECTION */
  4. if (mysqli_connect_errno()) {
  5. printf("Connect failed: %sn", mysqli_connect_error());
  6. exit();
  7. }
  8.  
  9. include 'mysql.conf.php';
  10.  
  11. if(isset($_POST['submit']) && !empty($_POST['user']) && !empty($_POST['password']))
  12. {
  13.  
  14. if($stmt = $con->prepare("SELECT * FROM admin WHERE user = ? AND password = ?")){ /* PREPARE YOUR QUERY */
  15. $stmt->bind_param("ss", $_POST['user'], $_POST['password']); /* BIND THESE TWO VARIABLES TO THE QUERY ABOVE RESPECTIVELY; s STANDS FOR strings */
  16. $stmt->execute(); /* EXECUTE THE QUERY */
  17. $stmt->store_result(); /* STORE THE RESULT */
  18. $noofrows = $stmt->num_rows; /* GET THE NUMBER OF RESULT */
  19. if($noofrows > 0){ /* CHECK IF RESULT IS MORE THAN 0 */
  20. echo "Login";
  21. } else {
  22. echo "Cannot Login";
  23. }
  24. $stmt->close(); /* CLOSE THE PREPARED STATEMENT */
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement