Advertisement
Guest User

Untitled

a guest
Jan 1st, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. 1.Make a config file:
  2. 2.download rb.php file (https://github.com/yeriomin/redbean-single-file/blob/master/rb.php) or from official site.
  3.  
  4. config.php
  5. ----------------------
  6.  
  7. include"rb.php";
  8. $username = "root";
  9. $userpass = "";
  10. $db = "shift";
  11. $host = "localhost";
  12. include "rb.php";
  13. R::setup("mysql:host=$host;dbname=$db", "$username", "$userpass"); //for both mysql or mariaDB
  14. R::ext('xdispense', function( $type ) { return R::getRedBean()->dispense($type);});
  15. R::freeze(true);
  16. //R::debug(true) ; put it true if you want to debug your query
  17.  
  18.  
  19. 2.
  20. include "config.php";
  21. $signin=isset($_POST['signin'])?$_POST['signin']:"";
  22. $username=isset($_POST['username'])?$_POST['username']:"";
  23. $pw=isset($_POST['pw'])?$_POST['pw']:"";
  24. if($username=="")
  25. {
  26. $error="fill in username to sign in "
  27. }
  28. else if($pw=="")
  29. {
  30. $error="fill in password to sign in "
  31. }
  32. else if($error=="")
  33. {
  34. $Query=R::getRow("SELECT pw FROM users WHERE username =:username",array(":username"=>$username));
  35. if(count($Query)>0)
  36. {
  37. if($pw===$Query["pw"])
  38. {
  39. print("Password match");
  40. //do what every you want here after password match
  41. }
  42. }
  43. else
  44. {
  45. echo $error;
  46. }
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. R::freeze(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement