如何在我的联系表单中的 php 中添加另一个复选框?

发布于 2024-08-23 21:40:33 字数 4465 浏览 6 评论 0原文

您好,我正在尝试向此 php 联系表单添加其他字段 我有一个复选框“您是否同意我们的业务条款”,但如何添加另一个复选框以选择加入营销。

感谢您的帮助

问候

朱迪

        <?php
$adminemail = '[email protected]'; // type your actual email address in place of [email protected]

$usesecimage = ''; // the path to a WSN Links, Gallery, KB or Forum install if you wish to borrow its security image prompt

$autoresponse = ''; // type the URL of a text file which should be used as the autoresponder body text

$controlvars = ' thankspage submitteremail ccsubmitter messagetosubmitter ';
$messagetoadmin = "A user has filled out a form with this content:


";

 if (!isset($_POST['messagetosubmitter'])) $messagetosubmitter = "You have submitted a form with the content listed below. Your submission will be reviewed, please be patient in awaiting a response.


";
 else $messagetosubmitter = $_POST['messagetosubmitter'];

while(list($key, $value) = each($_POST))
{
 if (!stristr($controlvars, ' '. $key .' '))
 {
  $messagetoadmin .= $key .': '. $value .'

';
  $messagetosubmitter .= $key .': '. $value .'

';
 }
} 
$submitter = $_POST['submitteremail'];
if ($submitter == '') $submitter = '[email protected]';
if (strstr($submitter, "\n") || strlen($submitter) > 50) die("Begone, foul spammer.");

if ($usesecimage)
{
 $curr_path = getcwd(); 
 chdir($usesecimage);        // Go to the WSN directory 
 require 'start.php'; 
 if (isset($_REQUEST['seed'])) $seed = $_REQUEST['seed']; else $seed = false;
 $correct = securityimagevalue($seed);
 if (strtolower($_POST['securityimage']) != $correct) die("You did not type the value from the image correctly. Press the back button.");
 chdir($curr_path);      // Return to original directory 
}

   session_start();
   if(empty($_POST['TermsOfBusiness']))
   {
    error_reporting(0);
    echo "You must agree to our Terms of Business. Please <a href='javascript: history.go(-1)'>click here</a> to return to the form";
   }
   elseif(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {

      mail("$adminemail, [email protected]", 'Form Submitted: '. stripslashes($_POST['subject']), stripslashes($messagetoadmin), 'From: '. $submitter);
      unset($_SESSION['security_code']);

   } else {
      error_reporting(0);
      echo "The security code you entered was incorrect, please click the back button on your browser to try again.";
   }

if ($_POST['ccsubmitter'] == 'yes')
{
 mail($submitteremail, 'Form Submitted: '. stripslashes($_POST['subject']), stripslashes($messagetosubmitter), 'From: '. $adminemail);
}
if ($autoresponse != '')
{
 $body = geturl($autoresponse);
 mail($submitteremail, 'Re: '. stripslashes($_POST['subject']), stripslashes($body), 'From: '. $adminemail);
}
header('Location: '. $_POST['thankspage']);
// just in case redirect doesn't work
die('<meta http-eqiv="refresh" content="0;url='. $_POST['thankspage'] .'">');

if (!function_exists('geturl'))
{
function geturl($url)
{
 if (extension_loaded('curl')) 
 {
   $user_agent = 'Mozilla/4.0 (compatible; MSIE 6.02; PHP)';
   $ch = curl_init(); 
   curl_setopt ($ch, CURLOPT_URL, $url); 
   curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); 
   curl_setopt ($ch, CURLOPT_HEADER, false); 
   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 
   curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);  // timeout after 5 seconds
   curl_setopt ($ch, CURLOPT_TIMEOUT, 15);  // timeout after 5 seconds   
   curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true); 
   $result = curl_exec ($ch); 
   curl_close ($ch); 
// curl_error($ch); // for debugging
   return $result;  
 }

 if (version_compare("4.3.0", phpversion(), "<"))
 { 
  $filecontents = @file_get_contents($url);
 }
 else
 {
  $fd = @fopen($url, 'rb');
  $filecontents = "";
  do 
  {
   $data = @fread($fd, 8192);
   if (strlen($data) == 0) 
   {
    break;
   }
   $filecontents .= $data;
  } while(true); 
  @fclose ($fd);
 }
 return $filecontents;
}
}

?>

Hi I'm trying to add some another field to this php contact form
I have a checkbox for "do you agree to our terms of business", but how do I add another one for opt in for Marketing.

Thanks for your help

Regards

Judi

        <?php
$adminemail = '[email protected]'; // type your actual email address in place of [email protected]

$usesecimage = ''; // the path to a WSN Links, Gallery, KB or Forum install if you wish to borrow its security image prompt

$autoresponse = ''; // type the URL of a text file which should be used as the autoresponder body text

$controlvars = ' thankspage submitteremail ccsubmitter messagetosubmitter ';
$messagetoadmin = "A user has filled out a form with this content:


";

 if (!isset($_POST['messagetosubmitter'])) $messagetosubmitter = "You have submitted a form with the content listed below. Your submission will be reviewed, please be patient in awaiting a response.


";
 else $messagetosubmitter = $_POST['messagetosubmitter'];

while(list($key, $value) = each($_POST))
{
 if (!stristr($controlvars, ' '. $key .' '))
 {
  $messagetoadmin .= $key .': '. $value .'

';
  $messagetosubmitter .= $key .': '. $value .'

';
 }
} 
$submitter = $_POST['submitteremail'];
if ($submitter == '') $submitter = '[email protected]';
if (strstr($submitter, "\n") || strlen($submitter) > 50) die("Begone, foul spammer.");

if ($usesecimage)
{
 $curr_path = getcwd(); 
 chdir($usesecimage);        // Go to the WSN directory 
 require 'start.php'; 
 if (isset($_REQUEST['seed'])) $seed = $_REQUEST['seed']; else $seed = false;
 $correct = securityimagevalue($seed);
 if (strtolower($_POST['securityimage']) != $correct) die("You did not type the value from the image correctly. Press the back button.");
 chdir($curr_path);      // Return to original directory 
}

   session_start();
   if(empty($_POST['TermsOfBusiness']))
   {
    error_reporting(0);
    echo "You must agree to our Terms of Business. Please <a href='javascript: history.go(-1)'>click here</a> to return to the form";
   }
   elseif(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {

      mail("$adminemail, [email protected]", 'Form Submitted: '. stripslashes($_POST['subject']), stripslashes($messagetoadmin), 'From: '. $submitter);
      unset($_SESSION['security_code']);

   } else {
      error_reporting(0);
      echo "The security code you entered was incorrect, please click the back button on your browser to try again.";
   }

if ($_POST['ccsubmitter'] == 'yes')
{
 mail($submitteremail, 'Form Submitted: '. stripslashes($_POST['subject']), stripslashes($messagetosubmitter), 'From: '. $adminemail);
}
if ($autoresponse != '')
{
 $body = geturl($autoresponse);
 mail($submitteremail, 'Re: '. stripslashes($_POST['subject']), stripslashes($body), 'From: '. $adminemail);
}
header('Location: '. $_POST['thankspage']);
// just in case redirect doesn't work
die('<meta http-eqiv="refresh" content="0;url='. $_POST['thankspage'] .'">');

if (!function_exists('geturl'))
{
function geturl($url)
{
 if (extension_loaded('curl')) 
 {
   $user_agent = 'Mozilla/4.0 (compatible; MSIE 6.02; PHP)';
   $ch = curl_init(); 
   curl_setopt ($ch, CURLOPT_URL, $url); 
   curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); 
   curl_setopt ($ch, CURLOPT_HEADER, false); 
   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 
   curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);  // timeout after 5 seconds
   curl_setopt ($ch, CURLOPT_TIMEOUT, 15);  // timeout after 5 seconds   
   curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true); 
   $result = curl_exec ($ch); 
   curl_close ($ch); 
// curl_error($ch); // for debugging
   return $result;  
 }

 if (version_compare("4.3.0", phpversion(), "<"))
 { 
  $filecontents = @file_get_contents($url);
 }
 else
 {
  $fd = @fopen($url, 'rb');
  $filecontents = "";
  do 
  {
   $data = @fread($fd, 8192);
   if (strlen($data) == 0) 
   {
    break;
   }
   $filecontents .= $data;
  } while(true); 
  @fclose ($fd);
 }
 return $filecontents;
}
}

?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

巨坚强 2024-08-30 21:40:33
  if(empty($_POST['TermsOfBusiness']))
   {
    error_reporting(0);
    echo "You must agree to our Terms of Business. Please click here to return to the form";
   }

该块根据需要检查业务条款。您可以在更改输入名称时简单地复制它:

  if(empty($_POST['Marketing']))
   {
    error_reporting(0);
    echo "(Place here your text for Marketing checkbox validation). Please click here to return to the form";
   }

  if(empty($_POST['TermsOfBusiness']))
   {
    error_reporting(0);
    echo "You must agree to our Terms of Business. Please click here to return to the form";
   }

This block checks Terms of Business as required. You can simply duplicate it while changing the input's name:

  if(empty($_POST['Marketing']))
   {
    error_reporting(0);
    echo "(Place here your text for Marketing checkbox validation). Please click here to return to the form";
   }

热血少△年 2024-08-30 21:40:33

这不是输入表单,此脚本处理来自表单的输入。

this is not the inputform, this script handles the input from the form.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文