Jump to content

Search the Community

Showing results for tags 'recaptcha'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 6 results

  1. I have a form that I decided to include Google recaptcha as an added measure of security. When I added the recaptcha it triggers an error because the recaptcha is not whitelisted. I read that HTML5 does not allow assigning the name attribute to div. i.e. <div name="myName"></div>. Against convention, I tried adding a name to the recaptcha div and adding that name to the whitelist. That approach failed. There is an iframe within the div that has the name attribute. I tried using the iframe name in the whitelist. That approach also failed. There is a hidden input that has an id="recaptcha-token". I added 'recaptcha-token' to the whitelist. This approach also failed. The hidden input is generated by the recaptcha api, so I don't think I have a means of assigning a name attribute to this input. Does anyone have a workaround or suggestion ? Note: form validation and whitelist all worked as expected prior to adding recaptcha. This is the div within the form. <div class="row"> <div class="col-md-12"> <div class="g-recaptcha" data-sitekey="<?php print $public_key;?>"></div> </div> </div> This is the code block using the whitelist. // VERIFY LEGITIMACY OF TOKEN if (verifyFormToken('form1')) { // Building a whitelist array with keys which will send through the form, no others would be accepted later on $whitelist = array('token','req-fName','req-lName','req-email','req-phone','req-address','req-city','req-state','req-zip','req-message','req_method','req-dateDepart','req-dateReturn','recaptcha-token','submit'); // Building an array with the $_POST-superglobal foreach ($_POST as $key=>$item) { // Check if the value $key (fieldname from $_POST) can be found in the whitelisting array, if not, die with a short message to the hacker if (!in_array($key, $whitelist)) { writeLog('Unknown form fields'); die('Hack-Attempt detected. Only the fields originally included in the form are allowed!'); } } } Thanks in advance for having a look at this.
  2. Hi all, I am sorry if I am posting this in the wrong place. If so, kindly transfer it to the appropriate section. I was using code that used recaptcha and that worked perfectly well. Now it has stopped working. The recaptcha dialog box simply does not display. Does anyone have any clue what could be going on? Has someone else also faced this similar problem recently Thanks all.
  3. I implemented google's reCAPTCHA V2 on http:// on the remote apache shared server and it worked 100%. I then changed the protocol to my shared server SSL using the same PHP script as the non-SSL script. The older version of reCaptcha had an SSL 'false' to 'true' SSL parameter, whereas I can't find one for V2. I had to use htaccess to redirect the example.com to the shared SSL server https://serverid.net/example/ which works perfectly without recCAPTCHA. I incorporated reCAPTCHA V2 and the error message where the reCAPTCHA image should be shows "ERROR: Invalid domain for site key". Here's the htaccess: RewriteEngine On RewriteCond %{HTTP_HOST} ^(.*)example\.com [NC] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://servername.net/example/$1 [R,L] And the recaptchalib.php code in case that helps: https://github.com/google/ReCAPTCHA/blob/master/php/recaptchalib.php Anyone know how to make this work? (If this is not the right forum for this, please direct me to the appropriate one. Thx)
  4. Hey guys, i was trying to add google recaptcha to my login register system, for a spam defense and just to give it a more professional feel. i already have my own conditional in my own system to make sure an email is not already used or to make sure a password is a certain length, etc.... i now want to add the existing code from google and add an additional conditional to make it flow as one. my issue so i followed the directions from goodle developers and when implementing the code by itself on a test page, i encounter no problems. i get the proper pass and fail, depending on what security code is entered. when i move that same logic into my already created system i then get a consistent failure with no pass. i am utterly confused as to why this is happening, if you guys can give me any suggestions that would be great. my code TEST PAGE .. WORKS FINE <?php include('include/init.php'); include('include/header.php'); require_once 'recaptchalib.php'; $privatekey = "6Lf5AeASAAAAAO5DJ1GcIAiwd8kkNbVBgrDrandom"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { echo 'FAILURE'; } else { echo 'SUCCESS'; // Your code here to handle a successful verification } ?> <tr> <form method='post' action='test.php' id='test'> <td class="register_td_left2"><span class="">Security Code:</span></td> <td valign="middle" style="padding-left:2px"> <?php require_once 'recaptchalib.php'; $publickey = "6Lf5AeASAAAAAPue6LLdUDttmPDc-NbRHcnrandom"; // you got this from the signup page echo recaptcha_get_html($publickey); ?></td> <input type='submit' value='Submit'></input> </form> </tr> Register page i try to implement the same logic require_once 'recaptchalib.php'; $privatekey = "6Lf5AeASAAAAAO5DJ1GcIAiwd8kkNbVBgrandom"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (empty($_POST) === false) { $required_fields = array('register_email','register_username','password','confirm_pass','gender','month','date','year','country'); foreach($_POST as $key => $value){ if (empty($value) && in_array($key, $required_fields) === true) { $errors[] = '* All fields are required!'; break 1; } } if (empty($errors) === true) { if (user_exists($_POST['register_username']) === true) { $errors[] = 'Sorry, the username \'' . $_POST['register_username'] . '\' has already been taken. Please choose another username.'; } if (preg_match("/\\s/", $_POST['register_username']) == true) { $errors[] = 'Sorry your username must not contain any spaces!'; } if (strlen($_POST['password']) < 6 ){ $errors[] = 'Your Password must be a minimal 6 characters long'; } if ($_POST['password'] !== $_POST['confirm_pass']) { $errors[] = 'Your Passwords do not match, please make sure both passwords are the same!'; } if (filter_var($_POST['register_email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'A valid email adress is required'; } if(email_exists($_POST['register_email']) === true){ $errors[] = 'The email you provided is already in use. If you are having trouble remembering your user info click <a href="#">here</a>'; } if (!$resp->is_valid) { $errors[] = 'You need to enter a valid security code'; } } } <form name="register" action="register.php" method="post"> <tr> <td class="register_td_left2"><span class="">Security Code:</span></td> <td valign="middle" style="padding-left:2px"> <?php require_once 'recaptchalib.php'; $publickey = "6Lf5AeASAAAAAPue6LLdUDttmPDc-NbRandom"; // you got this from the signup page echo recaptcha_get_html($publickey); ?></td> </tr> </form> i left out most of the form , just to save some reading time for you guys. figure its of no importance. again i am puzzled as to why this doesnt work for me on this page, yet on the test page it works fine. please i have been stuck on this for far to long for such a simple thing. thanks.
  5. Hi I have a form which collects information from a user, it also has an option to upload files. I placed a recaptcha control on the form to avoid bots. However the problem is i have many fields on the form which are lost if i give a wrong captcha. I'm using hidden fields to store input values, so if user enters wrong captcha i'm restoring field values from the hidden fields, however i don't know how this can be done if the input type is file. Is it possible to store file info in the hidden field too, is yes how? at the moment it is major problem if user enters wrong code after selecting some files. Thanks for any input.. yesvee
  6. Hi I'm new to php, i've been struggling for 2 days to write a simple code with recaptcha. My requirements is i have a registration form (reg.php) with 20 fields on it after all the required information is filled in the form data is submitted to Create Account page (CreateAccount.php). I placed a recaptcha control on the first page (reg.php) to secure the form from bots. I'm doing some javascript validation on the client side for required fields, and finally validating if correct recaptcha code is entered on the server side. That means the form is submitted to itself first for recaptcha validation, after the code is valid i want to resubmit the data to Account Creation page. i don't know how to do this. the CreateAccount.php has got a complex logic so i can not move it to the same reg.php page. i tried the following but with no luck... if ($_POST["recaptcha_response_field"]) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { //redirect to AccountCreation.php header("Location: AccountCreation.php"); } else { $error = $resp->error; } } please help me how this is done is php. Is there any other way of doing it simply...
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.