我使用電子郵件營銷公司發送HTML電子郵件,並在帖子中使用絕對路徑幷包含用於處理表單的隱藏變量。我想添加一個驗證碼,但不知道如何去做。所有的php captcha選項都會使用該帖子發佈到process.php頁面。我該怎麼做,並且仍然絕對地發佈給電子郵件營銷公司,包括隱藏變量?PHP表單:使用驗證碼發佈到絕對路徑
0
A
回答
0
如果我理解正確,你現在只需設置窗體的action
屬性的營銷公司的網址:
<form action="http://marketingsite.com/form.php" method="post">
......但現在,你需要在發送之前驗證數據。
一種方法是在您自己的網站process.php
內驗證您的數據,然後使用cURL
將數據發佈到市場營銷網站。當你安裝PHP
http://php.net/manual/en/book.curl.php
cURL
通常包括在內。它用於讀取數據並將數據發送給其他人的網頁。您可以選擇要發佈的數據,然後使用cURL
發佈。
<?php
// validate the CAPTCHA code first
// This array will hold the data that you are POSTing to the marketing site
$post = array();
// validate the other fields here, and add the relevant ones to an array. e.g.:
if(strlen($_POST['name']) > 4 && strlen($_POST['name'] < 20)) {
$post['name'] = $_POST['name'];
}
if(strlen($_POST['hiddenfield'] != 0)) {
$post['hiddenfield'] = $_POST['hiddenfield'];
}
// ...
$curl = curl_init();
// post the data to this url:
curl_setopt($curl,CURLOPT_URL,'http://marketingsite.com/form.php');
// This indicates that we are going to post some data:
curl_setopt($curl,CURLOPT_POST,true);
// Post this data:
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
// If your script successfully sent the data, && if http://marketingsite.com/form.php returned a 200 code
// (i.e.: not a 404 error or something)
if(curl_exec($curl) && curl_getinfo($curl,CURLINFO_HTTP_CODE) == 200) {
echo 'Thank you for submitting your data';
} else {
echo 'Your data was not submitted :(';
}
curl_close($curl);
?>
這會發布您選擇的所有內容,包括您要添加的隱藏字段或其他字段。
您還可以設置其他選項。您可以嘗試閱讀接收網頁並將該內容回傳到您的網站上。您可以瞭解更多關於cURL
和PHP
這裏:
+0
謝謝你的迴應。我會嘗試。 – wgoodman
相關問題
- 1. 絕對路徑PHP
- 2. PHP腳本絕對路徑
- 3. 絕對路徑的PHP
- 4. 使用絕對路徑,FileNotFoundError
- 5. PHP,最簡單的方法找到一個絕對路徑的相對路徑
- 6. PHP找到遠程絕對路徑
- 7. PHP表單驗證碼
- 8. 網絡路徑使絕對路徑 - asp.net
- 9. 使用PHP驗證表單並將數據發佈到Java應用程序
- 10. 絕對路徑
- 11. 絕對路徑
- 12. 使用絕對路徑或相對路徑陣營路線
- 13. 發佈與形式使用驗證碼
- 14. 使用PHP正則表達式驗證文件路徑
- 15. PHP包含絕對/相對路徑CSS
- 16. PHP需要路徑/相對或絕對
- 17. 驗證路徑
- 18. 使用絕對VS相對路徑調用資源在php
- 19. 相對路徑或絕對路徑
- 20. 絕對路徑和相對路徑
- 21. 改變相對路徑絕對路徑
- 22. Node.js:相對路徑和絕對路徑
- 23. PHP的require_once絕對路徑與相對路徑(不工作)
- 24. PHP:'智能'絕對路徑vs相對路徑
- 25. PHP轉換外部相對路徑絕對路徑
- 26. php的相對路徑和絕對路徑
- 27. 輸入絕對路徑,在PHP返回相對路徑
- 28. 結合的絕對路徑使用相對路徑
- 29. 使用codeigniter將ajax相對路徑轉換爲絕對路徑
- 30. 表單身份驗證cookie的相對路徑
鈣我們跟「絕對路徑」假設你的意思網址? – arkascha
是的,網址無誤。 – wgoodman