Guest User

Untitled

a guest
Apr 1st, 2018
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. __________MAIN_PAGE__________
  2.  
  3. require 'general.php';
  4.  
  5. if(checkCaptch($_POST['captchaInput']){
  6.     //Reload the page, allowing user to login
  7. }
  8. else{
  9.     die("Captcha is wrong");
  10. }
  11.  
  12. __________LOGIN_PAGE__________
  13.  
  14. require 'general.php';
  15.  
  16. function login(){
  17.     $sUser = $_POST['nameInput'];
  18.     $sPass = $_POST['passInput'];
  19.     $bLoginCorrect = false;
  20.     $bCaptchaCorrect = false;
  21.     $sError = "";
  22.     /*
  23.     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  24.     Check username and password in database, using valuable CPU and memory resources.
  25.     if everything works out then $bLoginCorrect = true;
  26.     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  27.     */
  28.     $bCaptchaCorrect = checkCaptch($_POST['captchaInput']);
  29.     if($bLoginCorrect){
  30.         if($bCaptchaCorrect){
  31.             /*
  32.             Yey login!
  33.             Go to to user section
  34.             */
  35.         }
  36.         else{
  37.             $sError .= "Captcha is wrong. ";
  38.         }
  39.     }
  40.     else{
  41.         sError .= "Username/Password is wrong";
  42.     }
  43.     die(sError);
  44. }
  45.  
  46. login();
  47.    
  48. __________GENERAL_PAGE__________(general.php)
  49.  
  50. $sCaptcha = getCurrentCaptcha();
  51.  
  52. function checkCaptch(){
  53.     if($_POST['captchaInput'] == $sCaptcha){
  54.         /*
  55.         Set all cookies/db entries/whatever to show captcha entered correctly.
  56.         However you are doing it right now, no changes are needed.
  57.         */
  58.         return true;
  59.     }
  60.     else{
  61.         return false;
  62.     }
  63. }
Add Comment
Please, Sign In to add comment