2012-11-02 21 views
3

我試圖幫助朋友修改一些舊的html代碼,以消除從web窗體傳遞給coldfusion函數的垃圾郵件。基本上,Web表單調用action = add_to_data.cfm。該朋友希望整合recaptcha以減少通過表單發送的垃圾郵件。我已經完成了該部分的工作並完成了reCaptcha驗證。問題是我不知道如何調用coldfusion「add_to_data.cfm」動作並傳遞表單數據。有很多recaptcha示例顯示了使用action = mailer.php的例子,但是我需要發送表單的數據到coldfusion - 「add_to_data.cfm。將reCaptcha整合到一個窗體的動作中.cfm

的原始形式:現在

<form method="post" action="add_to_data.CFm"> 
....blah, blah, blah ... form contents ... 

<input type="submit" value="Please add to my Data /> 
<form> 

,與來自谷歌開發的reCAPTCHA turtorial指導,而不是直接去「add_to_data.CFm,」唯一的辦法,我可以找出如何驗證驗證碼是將表單動作從「add_to_data.CFm」更改爲「動作」,以新創建「verify_recaptcha.php」,以便驗證recaptcha。

<form method="post" action="verify_recaptcha.php"> 
...original form contents ... 
     <?php 
      require_once('recaptchalib.php'); 
      $publickey = "your_public_key_goes_here"; 
      echo recaptcha_get_html($publickey); 
     ?> 
     <input type="submit" /> 
<form> 

這個例子是直接從谷歌開發的網頁進行驗證recpatcha與verify_recaptcha.php

<?php 
    require_once('recaptchalib.php'); 
    $privatekey = "your_private_key_goes_here"; 
    $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 

    *** this is where I need gather he form outputs and call add_to_data.CFM 
    *** but HOW?? 

    } 
    ?> 

所以我的問題是如何發送的「數據」到add_to_data.CFm?

我知道了「其他」部分的裏面上面,我可以得到表單變量是這樣的:

$name = $_POST['yourname']; 
$email = $_POST['email']; 
$data = $_POST['data']; 
$comments = $_POST['comments']; 
$formsub = $_POST['Submit']; 

所以現在的問題是:我如何填寫表格提交行動「add_to_data。 CFM「?

在此先感謝

回答

1

解決您的問題,最簡單的方法是讓CF驗證驗證碼。你可以在google上找到很多教程,我過去使用的教程就是下面的鏈接。

http://recaptcha.riaforge.org/

這是我根據我的最後執行過的基於標籤的實現,所以這樣做的工作。

否則,如果你真的想讓PHP把數據發送到CF,我想到的最簡單的方法是讓PHP自動提交一個表單將數據傳回CF.您需要一些額外的安全措施以確保沒有人劫持表單或嘗試繞過reCaptchadoing。我強烈建議在所有CF中進行驗證。

+0

是有道理的,但我不知道CF.哎呀,我幾乎可以做HTML :) – Steve

相關問題