Jump to content

reCAPTCHA + self processing php form (new)


Imokon

Recommended Posts

I have gained a lot of experience since my previous post;

http://www.phpfreaks.com/forums/index.php?topic=221124.0

 

however I am posting this new one because I have decided to use a brand new webring code package.

 

In this instance, the form I am trying to add the reCAPTCHA to is self processing, so it's harder to integrate the private and public keys together - it simply does not validate. I am trying hard to not get into using the ruby or a non script version (but will if there is absolutely no other choice).

 

So my question is, how do you make the reCAPTCHA validate in a self processing form?

 

Also please note, the webring has it's own basic CAPTCHA that I don't want, I want to use my own reCAPTCHA.

 

The code I don't care for found below;

 

  // get some stuff for the CAPTCHA
  $rand = rand( 10000, 99999 );
  $cap_cols = serialize( array( $_HIVEID['captcha_bkg'], $_HIVEID['captcha_txt'] ) );
  $cap_bdr = $_HIVEID['captcha_txt'][0] .', '. $_HIVEID['captcha_txt'][1] .', '. $_HIVEID['captcha_txt'][2];

 

The code I do want to insert is found here;

http://recaptcha.net/plugins/php/

 

The self processing form I am using;

 


<? include( "config.inc.php" );

   // check if we're accepting new members
   // if not, kill the page
   canJoin();

   $_PAGE_NAME = "Join";
   include( $_HIVEID['header'] );
  
  // data-check the form
  if( isset( $_POST['action'] ) && $_POST['action'] == 'join' )
    $error = checkUserData();
  
  // get some stuff for the CAPTCHA
  $rand = rand( 10000, 99999 );
  $cap_cols = serialize( array( $_HIVEID['captcha_bkg'], $_HIVEID['captcha_txt'] ) );
  $cap_bdr = $_HIVEID['captcha_txt'][0] .', '. $_HIVEID['captcha_txt'][1] .', '. $_HIVEID['captcha_txt'][2];

if( empty( $_POST['action'] ) || !empty( $error ) ){ ?>
  
  <h2>Join</h2>
  <p>
    Fill out the form below to join this fanlisting. Please make sure
    you've read the <a href="rules.php" title="Rules">rules</a> and if you have a website, that you put a
    <a href="codes.php" title="Codes">link</a> back up to <tt><strong><?=$_HIVEID['hiveurl']?></strong></tt> before joining!
  </p>
  <p>
    If you do not provide a password, one will be automatically
    generated for you.
  </p>
  <p>
    If you wish to update your member information, please
    <a href="edit.php" title="Edit User Information">click here</a>.
  </p>

<? if( !empty( $error ) ) { ?> 
  <p class="error"> 
    <strong>Error:</strong> <?=$error?>
  </p> 
<? } ?> 

  <form method="post" action="join.php" enctype="multipart/form-data">
  <fieldset>
    <legend>Personal Information</legend>
    <input type="hidden" name="action" value="join">
<?printJSAntiSpam( "j[doIt]" ); printCAPTCHAKey( $rand, "j[verseed]" );?>
  
    <label>
      <input type="text" name="j[memberName]" value="<?=@$_POST['j']['memberName']?>">
      Name
    </label>
    
    <label>
      <input type="password" name="j[memberPass]">
      Password
    </label>
    
    <label>
      <input type="password" name="j[memberPass2]">
      Password (Again)
    </label>
    
    <label>
      <input type="text" name="j[memberEmail]" value="<?=@$_POST['j']['memberEmail']?>">
      Email Address
    </label>
<? if( $_HIVEID['hivetype'] == 'FANLISTING' ){ ?> 
    <label class="form-inline">
      <input type="radio" name="j[memberEmailVis]" value="yes" checked> display email address
    </label>
    <label class="form-inline">
      <input type="radio" name="j[memberEmailVis]" value="no"> hide email address
    </label>
<? } if( $_HIVEID['captcha'] ){
  print "  <label for=\"bcap\">\n".
        "    <input type=\"text\" name=\"j[cap]\" maxlength=\"5\">\n".
        "    <img src=\"../vs.hive/captcha.inc.php?x=$rand&c=$cap_cols\"  style=\"border: 1px solid rgb( $cap_bdr );\" alt=\"CAPTCHA Image\">\n".
        "  </label>\n";
}
?>
  </fieldset>
  
  <fieldset>
    <legend>Membership Details</legend>
<? if( hasCountries() ){ ?> 
    <label>
      <? countryselect( 'j[memberCountry]', @$_POST['j']['memberCountry'] ); ?>
      Country
    </label>
<? } ?> 
    <label>
      <input type="text" name="j[memberURL]" value="<?=@$_POST['j']['memberURL']?>">
      URL
    </label>
<? if( $_HIVEID['usecodeurl'] ){ ?> 
    <label>
      <input type="text" name="j[memberCodeURL]" value="<?=@$_POST['j']['memberCodeURL']?>">
      Code URL
    </label>
<? } if( $_HIVEID['hivetype'] != 'FANLISTING' ){ ?> 
    <label>
      <input type="text" name="j[memberTxt1]" value="<?=@$_POST['j']['memberTxt1']?>">
      Site Name
    </label>
<? } if( hasQuestion() ) { ?> 
    <label>
      <input type="text" name="j[memberTxt2]" value="<?=@$_POST['j']['memberTxt2']?>">
      <?=hasQuestion()?>
    </label>
<? } if( $_HIVEID['hivetype'] == 'WEBRING' ) { ?> 
    <label>
      <textarea rows="3" name="j[memberTxt2]" cols="20"><?=@$_POST['j']['memberTxt2']?></textarea>
      Site Description
    </label>
<? } if ( $_HIVEID['usecom'] ) { ?> 
    <label>
      <textarea rows="3" name="j[memberCom]" cols="20"><?=@$_POST['j']['memberCom']?></textarea>
      Comment
    </label>
<? } ?>
  </fieldset>
  
  <fieldset class="submit-button">
    <legend>Submit</legend>
    <label>
      <input type="submit" name="submit" value="Join!" size="30">
    </label>
  </fieldset>
  </form>

<? } else { ?>

  <h2>Join</h2>
  <p>
    Thank you for your submission, </strong><?=@htmlspecialchars( $_POST['j']['memberName'], ENT_NOQUOTES, "UTF-8" )?></strong>. You should be added in the
    next update.
  </p>

<? }

  include( $_HIVEID['footer'] );
?>

Link to comment
https://forums.phpfreaks.com/topic/130926-recaptcha-self-processing-php-form-new/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.