Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $captcha = filter_input(INPUT_POST, 'captchaResponse'); // get the captchaResponse parameter sent from our ajax
- if (!$captcha) {
- echo 'no captcha';
- }
- $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=YOUR-SECRET-KEY-HERE&response=" . $captcha);
- if ($response . success == false) {
- //echo 'SPAM';
- // http_response_code(401); // It's SPAM! RETURN SOME KIND OF ERROR
- echo 'spam';
- } else {
- // Everything is ok and you can proceed by executing your login, signup, update etc scripts
- echo 'captcha good';
- }
- //LOGIN FORM
- $("#admin_loginForm").submit(function(event) {
- $('#loginResult').html('Please wait...');
- /* Send the request to teh server */
- $.ajax({
- type: 'POST', // The request type POST or GET
- url: "inc/functions.inc.php", // The URL to the controller
- dataType: 'html', // The data type json, html, img etc...
- async: true, // async or sync
- /* The main request body */
- data: {
- action: "logIn", // The action that we are catching at controller.php
- username: $('#username').val(), // Get the username user input
- password: $('#password').val(), // Get the password user input
- captchaResponse: $("#g-recaptcha-response").val()
- },
- success: function (data) {
- if(data == "false") {
- $('#loginResult').html('Enter your username & password!');
- }
- else {
- alert('all good');
- }
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- /* If something goes wrong we're comming here */
- alert(errorThrown);
- }
- });
- });
- $action = filter_input(INPUT_POST, 'action');
- if($action == "logIn") {
- $username = filter_input(INPUT_POST, 'username');
- $password = filter_input(INPUT_POST, 'password');
- if(empty($username)) {
- echo 'false';
- }
- else if(empty($password)) {
- echo 'false';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement