2012-01-16 33 views
0

これはphpとしてコード化されており、ローカルホストでは実行されていますが、実際のサーバーでは実行されていません。 recaptcha Imageはサーバーを通過する際に表示されません。代わりに、イメージなしのSOそれは私にこの声明を与える:INVALID ERROR:INVALID REFERER無効なエラー:Recaptchaのrefererが無効

コードがSIGN_UP.php

<form name="form1" method="post" action="signup_ac.php"> 
<?php 
require_once('recaptchalib.php'); 
$publickey = "6LcM0csSAAAAADwL24ky6_v0ZBO1l1ZzMqRVsJ7W"; // you got this from the signup page 
echo recaptcha_get_html($publickey); 
?> 
<table width="600" height="347" border="0" cellpadding="0" cellspacing="4"> 
<tr> 
    <td width="191" height="30" bgcolor="#DDDDDD">E-mail</td> 
    <td width="25" bgcolor="#DDDDDD" align="center">:</td> 
    <td width="368" bgcolor="#DDDDDD"><input name="email_add" type="text" id="email_add" onBlur="MM_validateForm('email_add','','RisEmail','password','','R','contact_name','','R','company_name','','R','phone_num','','R','date_created','','R','time_created','','R','address','','R');return document.MM_returnValue" size="50"></td> 
</tr> 
<tr> 
<td height="30" bgcolor="#DDDDDD">Password</td> 
<td bgcolor="#DDDDDD" align="center">:</td> 
<td bgcolor="#DDDDDD"><input name="password" type="text" id="password" size="50"></td> 
</tr> 
<tr> 
<td height="31" bgcolor="#DDDDDD">Your Name</td> 
<td bgcolor="#DDDDDD" align="center">:</td> 
<td bgcolor="#DDDDDD"><input name="contact_name" type = "text" id="contact_name" size="50"></td> 
</tr> 
<tr> 
<td height="31" bgcolor="#DDDDDD" onfocus="MM_validateForm('email_add','','RisEmail','password','','R','phone_num','','R');return document.MM_returnValue">Company Name</td> 
<td bgcolor="#DDDDDD" align="center">:</td> 
<td bgcolor="#DDDDDD"><input name="company_name" type="text" id="company_name" size="50"></td> 
</tr> 
<tr> 
<td height="31" bgcolor="#DDDDDD">Address</td> 
<td bgcolor="#DDDDDD" align="center">:</td> 
<td bgcolor="#DDDDDD"><textarea name="address" cols="50" rows="5" id="address"></textarea></td> 
</tr> 
<td height="35" bgcolor="#DDDDDD">Phone Number</td> 
<td bgcolor="#DDDDDD" align="center">:</td> 
<td bgcolor="#DDDDDD"><input name="phone_num" type="text" id="phone_num" size="50"></td> 
</tr> 
<td height="31" bgcolor="#DDDDDD">Fax</td> 
<td bgcolor="#DDDDDD" align="center">:</td> 
<td bgcolor="#DDDDDD"><input name="fax" type="text" id="fax" size="50"></td> 
</tr> 
<td height="36" bgcolor="#DDDDDD">Date Created</td> 
<td bgcolor="#DDDDDD" align="center">:</td> 
<td bgcolor="#DDDDDD"><input name="date_created" type="text" id="date_created" size="50"></td> 
</tr> 
<td height="29" bgcolor="#DDDDDD"><p>Time Created</p> 
    <p> (hh : mm)am/pm</p></td> 
<td bgcolor="#DDDDDD" align="center">:</td> 
<td bgcolor="#DDDDDD"><input name="time_created" type="text" id="time_created" size="50"></td> 
</tr> 

<tr> 
<td height="31">&nbsp;</td> 
<td>&nbsp;</td> 
<td>&nbsp; 
    <div align="right"> 
    <input type="reset" name="Reset" value="Reset"> 
    <input type="submit" name="Submit" value="Submit" /> 
    </div></td> 
</tr> 
</table> 
</form> 

**Then SIGNUP_AC.php CODE to PRocess the code which is suppose to run after the SUGNUP.php is submitted. and then verify the user through Email that they provided during registeration:** 
<? 

    require_once('recaptchalib.php'); 
    $privatekey = "your_private_key"; 
    $resp = recaptcha_check_answer ($privatekey, 
           $_SERVER["REMOTE_ADDR"], 
           $_POST["recaptcha_challenge_field"], 
           $_POST["recaptcha_response_field"]); 

    if (!$resp->is_valid) { 
    // What happens when the CAPTCHA was entered incorrectly 
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . 
     "(reCAPTCHA said: " . $resp->error . ")"); 
    } else { 
    // Your code here to handle a successful verification 

      $host="localhost"; // Host name 
      $username="root"; // Mysql username 
      $password=""; // Mysql password 
      $db_name="purchase_try"; // Database name 
      //$tbl_name="temp_members_db"; // Table name 

      // Connect to server and select database. 
      mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
      mysql_select_db("$db_name")or die("cannot select DB"); 

      // table name 
      //$tbl_name= "temp_members_db"; 

      // Random confirmation code 
      //$confirm_code = md5(uniqid(rand())); 

// values sent from form 
$email_add  = $_POST['email_add']; 
$password  = $_POST['password']; 
$contact_name = $_POST['contact_name']; 
$company_name = $_POST['company_name']; 
$address  = $_POST['address']; 
$phone_num  = $_POST['phone_num']; 
$fax   = $_POST['fax']; 
$date_created = $_POST['date_created']; 
$time_created = $_POST['time_created'];   

      // Insert data into database 
      $sql="INSERT INTO temp_members_db(confirm_code, 
               email_add, 
               password, 
               company_name, 
               contact_name, 
               address, 
               phone_num, 
               fax_num, 
               date_created, 
               time_created) 
                  VALUES('".$confirm_code."', 
                    '".$email_add."', 
                    '".$password."', 
                    '".$company_name."', 
                    '".$contact_name."' 
                    '".$address."', 
                    '".$phone_num."', 
                    '".$fax."', 
                    '".$date_created."', 
                     '".$time_created."')"; 

      $result = mysql_query($sql); 

      if($result){ 
      echo "Successful"; 

      } 

      else { 
      echo "ERROR"; 
      } 

      // close connection 
      mysql_close(); 

      // if suceesfully inserted data into database, send confirmation link to email 
      if($result){ 

      // ---------------- SEND MAIL FORM ---------------- 

      // send e-mail to ... 
      $to = $email_add; 

      // Your subject 
      $subject = "Your confirmation link here"; 

      // From 
      $header = "from: your name <[email protected]>"; 

      // Your message 

      $message = "Your Comfirmation link \r\n"; 
      $message .= "Click on this link to activate your account \r\n"; 
      $message .= "http://www.yourweb.com/confirmation.php?passkey=$confirm_code"; 

      // send email 
      $sentmail = mail($to,$subject,$message,$header); 

      } 

      // if not found 
      else { 
      echo "Not found your email in our database"; 
      } 

      // if your email succesfully sent 
      if($sentmail){ 
      header('location: register_confirm_mssg.php'); 
      } 
      else { 
      header('location: email_notsent.php'); 
      } 

    } 


?> 
+0

有効なキーを使用していますか? –

+0

私はgoogle.comを使用してキーを作り、自分のドメインhttp://recaptchaproduct.net(グローバルにしたもの)を作り、私の鍵を手に入れました。その後、私は何をする必要がありますか?コードにどこにドメイン名を挿入しますか? –

答えて

1

ためである一般的にそのエラーは、Googleからの鍵のペアを取得しているとき、として起こりますapi、そこにドメイン名を指定します。そこで、ローカルシステムでこれらのキーを使用するには、domainを "localhost"と入力します。ただし、これらのキーのペアは、そのアプリケーションを任意のサーバーにデプロイすると機能しません。

リモートホストでアプリケーションを動作させるには、アプリケーションを配備するドメイン名を持つgoogle apiからキーのペアを取得する必要があります。そしてあなたのアプリケーションでそれらを使用してください。

これは何らかの形で役立ちます。

+0

あなたは私のロカストの名前を変更する必要があると言っていますか? –

+0

私はキーをhttp://recaptchaproduct.net を使用して作成したので、$ localhost = "locahost"を置き換えます。 $ localhost = "http://recaptcha.net"; ? –

+0

申し訳ありません、ここをクリックして設定を変更してください。もう1つの質問はrecaptchalib.phpにこれらを定義することです。 このように:/ ** * reCAPTCHAサーバーURLの */ define( "RECAPTCHA_API_SERVER"、 "http://www.google.com/recaptcha/api "); define( "RECAPTCHA_API_SECURE_SERVER"、 "https://www.google.com/recaptcha/api"); define( "RECAPTCHA_VERIFY_SERVER"、 "http://recaptchaproduct.net"); –

0

無効なrefererエラーは、ローカルホスト用に作成された公開鍵と非公開鍵が実際のサーバ用ではないことが原因です。 にサインアップして新しいキーを作成する必要がありますhttp://recaptcha.net

関連する問題