Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将表单链接到php以获取验证码,将成功链接到表单流程,发送不带正文/页眉信息的电子邮件_Php_Forms_Process_Linker_Captcha - Fatal编程技术网

将表单链接到php以获取验证码,将成功链接到表单流程,发送不带正文/页眉信息的电子邮件

将表单链接到php以获取验证码,将成功链接到表单流程,发送不带正文/页眉信息的电子邮件,php,forms,process,linker,captcha,Php,Forms,Process,Linker,Captcha,使用验证码处理相当简单的表单 这是我第一次处理验证码,所以我使用了一个预构建的设置“quickcaptcha 1.0” 目前一切正常 表单、验证码(流程除外) 我想这与变量之间的链接量有关 以下是我认为应该发生的事情。 表单显示给用户,用户在信息中键入。 通过“requestresult.php”在提交按钮后检查验证码 然后,如果成功,它将其交给“resultsettings.php”,然后在resultsettings中将其发送到“requestprocess.php”,后者从初始reques

使用验证码处理相当简单的表单 这是我第一次处理验证码,所以我使用了一个预构建的设置“quickcaptcha 1.0”

目前一切正常 表单、验证码(流程除外) 我想这与变量之间的链接量有关

以下是我认为应该发生的事情。 表单显示给用户,用户在信息中键入。 通过“requestresult.php”在提交按钮后检查验证码 然后,如果成功,它将其交给“resultsettings.php”,然后在resultsettings中将其发送到“requestprocess.php”,后者从初始request.php表单收集include中的变量

我不确定……现在它发送了两封电子邮件,一封是身体信息,没有附加输入信息,另一封是下面什么都没有

这是密码

request.php:

<?
        /* Subject and Email Variables */

    $emailSubject = 'Request Form';
    $webMaster = 'info@mywebhost.com';

        /* Gathering Data Variables */

    $nameField = $_POST['name'];
    $aliasField = $_POST['alias'];
    $cellField = $_POST['cell'];
    $emailField = str_replace( "\r\n", '', $_POST['email'] );
    $boardField = $_POST['board'];
    $refname1Field = $_POST['refname1'];
    $refcontact1Field = $_POST['refcontact1'];
    $refname2Field = $_POST['refname2'];
    $workinfoField = $_POST['workinfo'];
    $worknameField = $_POST['workname'];
    $workaddyField = $_POST['workaddy'];
    $switchnoField = $_POST['switchno'];
    $directnoField = $_POST['directno'];



        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <link href="nrlayouts.css" rel=stylesheet type=text/css />
        <script type="text/javascript">
       // <![CDATA[
        function display(obj,id1,id2) {
        txt = obj.options[obj.selectedIndex].value;
        document.getElementById(id1).style.display = 'none';
         document.getElementById(id2).style.display = 'none';
        if ( txt.match(id1) ) {
         document.getElementById(id1).style.display = 'block';
        }
        if ( txt.match(id2) ) {
        document.getElementById(id2).style.display = 'block';
        }
        }
        // ]]>
        </script>

        </head>
          <body bgcolor="#CCC"><form action="requestresult.php" method="post">
              <table width="540" border="0" cellspacing="5" cellpadding="0">
                <tr>
                  <td width="250" align="right"><label for="name7">Full Name:</label>        </td>
                  <td width="250" align="left"><input type="text" name="name"        id="name" />         </td>
                 </tr>
                <tr>
                  <td width="250" align="right"><label for="alias">Alias:</label></td>
                  <td width="250" align="left"><input type="text" name="alias" id="alias" />     </td>
                </tr>
                <tr>
                  <td width="250" align="right"><label for="cell">Cellphone:</label>        </td>
                  <td width="250" align="left"><input type="text" name="cell"        id="cell" />     </td>
                </tr>
                <tr>
                  <td width="250" align="right"><label for="email">Email:</label></td>
                  <td width="250" align="left"><input type="text" name="email" id="email" />     </td>
                </tr>
                <tr>
                  <td width="250" align="right"><label for="board">Board:</label></td>
                  <td width="250" align="left"><input type="text" name="board" id="board" /></td>
                </tr>
                <td class="title">References?</td>
         <td class="field">
         <select name="type" onchange="display(this,'References','workinfo');">
         <option>Do you have References?:</option>
         <option value="References">Yes</option>
         <option value="workinfo">No</option>
         </select>
                </tr>
         </thead>
         <tfoot>
         <tr>
         <td class="title">Please Prove You are Human:  <img          src="quickcaptcha/imagebuilder.php" border="1"></td>
          <td><input MAXLENGTH=8 SIZE=8 name="userstring" type="text" value=""></td>
          <td></td>
          </tr>
          <tr>
          <td class="align-center" colspan="2"><input type="submit" name="submit" value="Send Email!" /> <input type="reset" value="Reset" /></td>
          </tr>
          </tfoot>
           <tbody id="References" style="display: none;">
         <tr>
         <td class="title">Reference Name:</td>
         <td class="field"><input type="text" name="refname1" size="20" maxlength="20" />        </td>
          </tr>
          <tr>
          <td class="title">Reference Contact:</td>
           <td class="field"><input type="text" name="refcontact1" size="20" maxlength="30" /></td>
           </tr>
          <tr>
            <td class="title">Reference Name:</td>
             <td class="field"><input type="text" name="refname2" size="20" maxlength="20" /></td>
           </tr>
            <tr>
           <td class="title">Reference Contact:</td>
           <td class="field"><input type="text" name="refcontact2" size="20" maxlength="30" /></td>
           </tr>
           </tbody>
           <tbody id="workinfo" style="display: none;">
           <tr>
           <td class="title">Work Information:</td>
           <td class="field"><input type="text" name="workinfo" size="20" maxlength="30" />         </td>
           </tr>
           <tr>
           <td class="title">Employer's Name:</td>
           <td class="field"><input type="text" name="workname" size="20" maxlength="30" /></td>
           </tr>
           <tr>
           <td class="title">Employer's Address:</td>
           <td class="field"><input type="textarea" name="workaddy" size="20" maxlength="30" /></td>
            </tr>
            <tr>
            <td class="title">Main Switchboard Number:</td>
            <td class="field"><input type="text" name="switchno" size="20" maxlength="20"/>          </td>
            </tr>
            <tr>
            <td class="title">Direct Line:</td>
                   <td class="field"><input type="text" name="directno" size="20" maxlength="20" />       </td>
             </tr>
              </table>
            </form>
            </body>
            </html>

// 
全名:
别名:
手机:
电邮:
董事会:
推荐人?
你有推荐信吗
对
不
请证明你是人类:
参考名称:
参考联系人:
参考名称:
参考联系人:
工作资料:
雇主名称:
雇主地址:
总机号码:
直达电话:
requestsettings.php

<?php

    // This string contains allowable characters for the image.
    // To reduce confusion, zero and the letter 'o' have been removed,
    // and QuickCaptcha is NOT case-sensitive.
    $acceptedChars = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';

    // Number of characters in image.
    $stringlength = 5;

    // Where to go when the correct / incorrect code is entered.
    $success = "requestprocess.php";
    $failure = "failure.html";

    // A value between 0 and 100 describing how much color overlap
    // there is between text and other objects.  Lower is more
    // secure against bots, but also harder to read.
    $contrast = 60;

    // Various obfuscation techniques.
    $num_polygons = 3; // Number of triangles to draw.  0 = none
    $num_ellipses = 6;  // Number of ellipses to draw.  0 = none
    $num_lines = 0;  // Number of lines to draw.  0 = none
    $num_dots = 0;  // Number of dots to draw.  0 = none

    $min_thickness = 2;  // Minimum thickness in pixels of lines
    $max_thickness = 8;  // Maximum thickness in pixles of lines
    $min_radius = 5;  // Minimum radius in pixels of ellipses
    $max_radius = 15;  // Maximum radius in pixels of ellipses

    // How opaque should the obscuring objects be. 0 is opaque, 127
    // is transparent.
    $object_alpha = 75;
    ?>

requestresult.php:

<?php

    include "requestsettings.php";

    session_start();
    $string = strtoupper($_SESSION['string']);
    $userstring = strtoupper($_POST['userstring']); 
    session_destroy();   

    if (($string == $userstring) && (strlen($string) > 4)) {
header("Location: $success");
exit();
      } else {
header("Location: $failure");
exit();
       }
      ?>

requestprocess.php

<?php
      include_once "request.php";

$emailSubject = 'Request Form';
$webMaster = 'info@mywebhost.com';


$body = <<<EOD
   <br><hr><br>
  Name: $nameField <br>
  Alias: $aliasField <br>
  Cellphone: $cellField <br>
  Email: $emailField <br>
  Board: $boardField <br>
  Reference Name1: $refname1Field <br>
  Reference Contact1: $refcontact1Field <br>
  Reference Name2: $refname2Field <br>
  Reference Contact2: $refcontact2Field <br>
  Work Information: $workinfoField <br>
  Work Name: $worknameField <br>
  Work Address: $workaddyField <br>
  Switchboard Number: $switchnoField <br>
  Direct Line: $directnoField <br>
    EOD;

$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

      /* Results rendered as HTML */
     $result = "Thank you!  Your request will be answered shortly.";
        if($success){
echo "$result";
      }else{
echo "There was an error with your submission";
exit;
      }
     ?>
<?php

$emailSubject = 'Request Form';
$webMaster = 'youremail@somewhere.com';

        /* Gathering Data Variables */

    $nameField = $_POST['name'];
    $aliasField = $_POST['alias'];
    $cellField = $_POST['cell'];
    $emailField = str_replace( "\r\n", '', $_POST['email'] );
    $boardField = $_POST['board'];
    $refname1Field = $_POST['refname1'];
    $refcontact1Field = $_POST['refcontact1'];
    $refname2Field = $_POST['refname2'];
    $workinfoField = $_POST['workinfo'];
    $worknameField = $_POST['workname'];
    $workaddyField = $_POST['workaddy'];
    $switchnoField = $_POST['switchno'];
    $directnoField = $_POST['directno'];

$body = "
   <br><hr><br>
  Name: $nameField <br>
  Alias: $aliasField <br>
  Cellphone: $cellField <br>
  Email: $emailField <br>
  Board: $boardField <br>
  Reference Name1: $refname1Field <br>
  Reference Contact1: $refcontact1Field <br>
  Reference Name2: $refname2Field <br>
  Reference Contact2: $refcontact2Field <br>
  Work Information: $workinfoField <br>
  Work Name: $worknameField <br>
  Work Address: $workaddyField <br>
  Switchboard Number: $switchnoField <br>
  Direct Line: $directnoField <br>
";


$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

      /* Results rendered as HTML */
     $result = "Thank you! Your request will be answered shortly.";

// NOTE: produces an error, commented out
//        if($success){
echo "$result";
//      }else{
//echo "There was an error with your submission";
//exit;
//      }

?>

imagebuilder.php

<?php
include "settings.php";

// Keep #'s reasonable.
$min_thickness = max(1,$min_thickness);
$max_thickness = min(20,$max_thickness);
// Make radii into height/width
$min_radius *= 2;
$max_radius *= 2;
// Renormalize contrast
$contrast = 255 * ($contrast / 100.0);
$o_contrast = 1.3 * $contrast;

$width = 15 * imagefontwidth (5);
$height = 2.5 * imagefontheight (5);
$image = imagecreatetruecolor ($width, $height);
imagealphablending($image, true);
$black = imagecolorallocatealpha($image,0,0,0,0);

// Build the  validation string
$max = strlen($acceptedChars)-1;
$password = NULL;
for($i=0; $i < $stringlength; $i++) {
    $cnum[$i] = $acceptedChars{mt_rand(0, $max)};
    $password .= $cnum[$i];
}

// Add string to image
$rotated = imagecreatetruecolor (70, 70);
$x = 0;
for ($i = 0; $i < $stringlength; $i++) {
    $buffer = imagecreatetruecolor (20, 20);
    $buffer2 = imagecreatetruecolor (40, 40);

    // Get a random color
    $red = mt_rand(0,255);
    $green = mt_rand(0,255);
    $blue = 255 - sqrt($red * $red + $green * $green);
    $color = imagecolorallocate ($buffer, $red, $green, $blue);

    // Create character
    imagestring($buffer, 5, 0, 0, $cnum[$i], $color);

    // Resize character
    imagecopyresized ($buffer2, $buffer, 0, 0, 0, 0, 25 + mt_rand(0,12), 25 + mt_rand(0,12), 20, 20);

    // Rotate characters a little
    $rotated = imagerotate($buffer2, mt_rand(-25, 25),imagecolorallocatealpha($buffer2,0,0,0,0)); 
    imagecolortransparent ($rotated, imagecolorallocatealpha($rotated,0,0,0,0));

    // Move characters around a little
    $y = mt_rand(1, 3);
    $x += mt_rand(2, 6); 
    imagecopymerge ($image, $rotated, $x, $y, 0, 0, 40, 40, 100);
    $x += 22;

    imagedestroy ($buffer); 
    imagedestroy ($buffer2); 
}

// Draw polygons
if ($num_polygons > 0) for ($i = 0; $i < $num_polygons; $i++) {
    $vertices = array (
        mt_rand(-0.25*$width,$width*1.25),mt_rand(-0.25*$width,$width*1.25),
        mt_rand(-0.25*$width,$width*1.25),mt_rand(-0.25*$width,$width*1.25),
        mt_rand(-0.25*$width,$width*1.25),mt_rand(-0.25*$width,$width*1.25)
    );
    $color = imagecolorallocatealpha ($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), $object_alpha);
    imagefilledpolygon($image, $vertices, 3, $color);  
}

// Draw random circles
if ($num_ellipses > 0) for ($i = 0; $i < $num_ellipses; $i++) {
    $x1 = mt_rand(0,$width);
    $y1 = mt_rand(0,$height);
    $color = imagecolorallocatealpha ($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), $object_alpha);
//  $color = imagecolorallocate($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast));
    imagefilledellipse($image, $x1, $y1, mt_rand($min_radius,$max_radius), mt_rand($min_radius,$max_radius), $color);  
}

// Draw random lines
if ($num_lines > 0) for ($i = 0; $i < $num_lines; $i++) {
    $x1 = mt_rand(-$width*0.25,$width*1.25);
    $y1 = mt_rand(-$height*0.25,$height*1.25);
    $x2 = mt_rand(-$width*0.25,$width*1.25);
    $y2 = mt_rand(-$height*0.25,$height*1.25);
    $color = imagecolorallocatealpha ($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), $object_alpha);
    imagesetthickness ($image, mt_rand($min_thickness,$max_thickness));
    imageline($image, $x1, $y1, $x2, $y2 , $color);  
}

// Draw random dots
if ($num_dots > 0) for ($i = 0; $i < $num_dots; $i++) {
    $x1 = mt_rand(0,$width);
    $y1 = mt_rand(0,$height);
    $color = imagecolorallocatealpha ($image, mt_rand(0,$o_contrast), mt_rand(0,$o_contrast), mt_rand(0,$o_contrast),$object_alpha);
    imagesetpixel($image, $x1, $y1, $color);
}

session_start();
$_SESSION['string'] = $password;

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);

?>
这是修改后的表单(request.php)-
注意:请确保修改imagebuilder.php文件的路径

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link href="nrlayouts.css" rel=stylesheet type=text/css />
    <script type="text/javascript">
   // <![CDATA[
    function display(obj,id1,id2) {
    txt = obj.options[obj.selectedIndex].value;
    document.getElementById(id1).style.display = 'none';
     document.getElementById(id2).style.display = 'none';
    if ( txt.match(id1) ) {
     document.getElementById(id1).style.display = 'block';
    }
    if ( txt.match(id2) ) {
    document.getElementById(id2).style.display = 'block';
    }
    }
    // ]]>
    </script>

    </head>
      <body bgcolor="#CCC">
          <table width="540" border="0" cellspacing="5" cellpadding="0">
<form action="requestprocess.php" method="post">
            <tr>
              <td width="250" align="right"><label for="name7">Full Name:</label>        </td>
              <td width="250" align="left"><input type="text" name="name"        id="name" />         </td>
             </tr>
            <tr>
              <td width="250" align="right"><label for="alias">Alias:</label></td>
              <td width="250" align="left"><input type="text" name="alias" id="alias" />     </td>
            </tr>
            <tr>
              <td width="250" align="right"><label for="cell">Cellphone:</label>        </td>
              <td width="250" align="left"><input type="text" name="cell"        id="cell" />     </td>
            </tr>
            <tr>
              <td width="250" align="right"><label for="email">Email:</label></td>
              <td width="250" align="left"><input type="text" name="email" id="email" />     </td>
            </tr>
            <tr>
              <td width="250" align="right"><label for="board">Board:</label></td>
              <td width="250" align="left"><input type="text" name="board" id="board" /></td>
            </tr>
            <td class="title">References?</td>
     <td class="field">
     <select name="type" onchange="display(this,'References','workinfo');">
     <option>Do you have References?:</option>
     <option value="References">Yes</option>
     <option value="workinfo">No</option>
     </select>
            </tr>
     </thead>
     <tfoot>
     <tr>
     <td class="title">Please Prove You are Human:  <img src="imagebuilder.php" border="1"></td>
      <td><input MAXLENGTH=8 SIZE=8 name="userstring" type="text" value=""></td>
      <td></td>
      </tr>
      <tr>
      <td class="align-center" colspan="2"><input type="submit" name="submit" value="Send Email!" /> <input type="reset" value="Reset" /></td>
      </tr>
      </tfoot>
       <tbody id="References" style="display: none;">
     <tr>
     <td class="title">Reference Name:</td>
     <td class="field"><input type="text" name="refname1" size="20" maxlength="20" />        </td>
      </tr>
      <tr>
      <td class="title">Reference Contact:</td>
       <td class="field"><input type="text" name="refcontact1" size="20" maxlength="30" /></td>
       </tr>
      <tr>
        <td class="title">Reference Name:</td>
         <td class="field"><input type="text" name="refname2" size="20" maxlength="20" /></td>
       </tr>
        <tr>
       <td class="title">Reference Contact:</td>
       <td class="field"><input type="text" name="refcontact2" size="20" maxlength="30" /></td>
       </tr>
       </tbody>
       <tbody id="workinfo" style="display: none;">
       <tr>
       <td class="title">Work Information:</td>
       <td class="field"><input type="text" name="workinfo" size="20" maxlength="30" />         </td>
       </tr>
       <tr>
       <td class="title">Employer's Name:</td>
       <td class="field"><input type="text" name="workname" size="20" maxlength="30" /></td>
       </tr>
       <tr>
       <td class="title">Employer's Address:</td>
       <td class="field"><input type="textarea" name="workaddy" size="20" maxlength="30" /></td>
        </tr>
        <tr>
        <td class="title">Main Switchboard Number:</td>
        <td class="field"><input type="text" name="switchno" size="20" maxlength="20"/>          </td>
        </tr>
        <tr>
        <td class="title">Direct Line:</td>
               <td class="field"><input type="text" name="directno" size="20" maxlength="20" />       </td>
         </tr>
        </form>
          </table>

        </body>
        </html>

// 
全名:
别名:
手机:
电邮:
董事会:
推荐人?
你有推荐信吗
对
不
请证明你是人类:
参考名称:
参考联系人:
参考名称:
参考联系人:
工作资料:
雇主名称:
雇主地址:
总机号码:
直达电话:
下面是修改后的流程(requestprocess.php)


下面是requestsettings.php(修改了第14行,$success=…等)



我更改了一些文件。您可以根据自己的喜好修改它们,但可以使用副本进行测试。让我知道它是如何为你工作的,它为我工作的。

我不完全确定,但有两个重复的
$success=mail($webMaster,$emailSubject,$body,$headers)可能是出了什么问题。您是否尝试过将一个设置为
$success1…
$success2…
?如果没有
imagebuilder.php
源代码,我无法为您测试它。我删除了顶部的$success=mail(),它只发送了一封电子邮件,但我仍然没有得到任何信息。我想,既然显示了$result,电子邮件显示验证码运行良好…但如果你愿意,我会发布。没关系,我需要整个库文件。我现在下载了,看看我能为你做些什么。在我将变量移回request.php之前,我认为我已经有了这个功能,但它不起作用。不知怎么的,现在是这样了。谢谢你。@Chickpea马上就来,我很高兴这对你有用,干杯;)很高兴我能帮上忙。@鹰嘴豆给我一个错误的东西是
$body=
<?php

// This string contains allowable characters for the image.
// To reduce confusion, zero and the letter 'o' have been removed,
// and QuickCaptcha is NOT case-sensitive.
$acceptedChars = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';

// Number of characters in image.
$stringlength = 5;

// Where to go when the correct / incorrect code is entered.
//    $success = "requestprocess.php";

$success = "success.html";
$failure = "failure.html";

// A value between 0 and 100 describing how much color overlap
// there is between text and other objects.  Lower is more
// secure against bots, but also harder to read.
$contrast = 60;

// Various obfuscation techniques.
$num_polygons = 3; // Number of triangles to draw.  0 = none
$num_ellipses = 6;  // Number of ellipses to draw.  0 = none
$num_lines = 0;  // Number of lines to draw.  0 = none
$num_dots = 0;  // Number of dots to draw.  0 = none

$min_thickness = 2;  // Minimum thickness in pixels of lines
$max_thickness = 8;  // Maximum thickness in pixles of lines
$min_radius = 5;  // Minimum radius in pixels of ellipses
$max_radius = 15;  // Maximum radius in pixels of ellipses

// How opaque should the obscuring objects be. 0 is opaque, 127
// is transparent.
$object_alpha = 75;
?>