Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __________MAIN_PAGE__________
- require 'general.php';
- if(checkCaptcha($_POST['captchaInput']){
- //Reload the page, allowing user to get to login page
- }
- else{
- die("Captcha is wrong");
- }
- __________LOGIN_PAGE__________
- require 'general.php';
- function login(){
- $sUser = $_POST['nameInput'];
- $sPass = $_POST['passInput'];
- $bLoginCorrect = false;
- $bCaptchaCorrect = false;
- $sError = "";
- /*
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- Check username and password in database, using valuable CPU and memory resources.
- if everything works out then $bLoginCorrect = true;
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- */
- $bCaptchaCorrect = checkCaptch($_POST['captchaInput']);
- if($bLoginCorrect){
- if($bCaptchaCorrect){
- /*
- Yey login!
- Go to to user section
- */
- }
- else{
- $sError .= "Captcha is wrong. ";
- }
- }
- else{
- sError .= "Username/Password is wrong";
- }
- die(sError);
- }
- login();
- __________GENERAL_PAGE__________(general.php)
- $sCaptcha = getCurrentCaptcha();
- function checkCaptcha(){
- if($_POST['captchaInput'] == $sCaptcha){
- /*
- Set all cookies/db entries/whatever to show captcha entered correctly.
- However you are doing it right now, no changes are needed.
- */
- return true;
- }
- else{
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement