PHP recaptcha 发送邮件问题

发布于 2024-09-03 15:09:57 字数 3060 浏览 1 评论 0原文

嘿伙计们,如果有人能帮助我,我会很高兴...

我所拥有的是一个已发送的表格,使用 doublecheck.php

<?php  
    require_once('recaptchalib.php');  
    $privatekey = "";  
    $resp = recaptcha_check_answer ($privatekey,  
    $_SERVER["REMOTE_ADDR"],   
    $_POST["recaptcha_challenge_field"],  
    $_POST["recaptcha_response_field"]);  
    if (!$resp->is_valid) {  
        die ("Sorry please go back and try it again." .  
            "" . $resp->error . ")");  
    }  
    if ($resp->is_valid) {  
        require_once('sendmail.php');  
    }    
?>

然后是我的 sendmail.php

<?php

    $ip = $_POST['ip'];
    $httpref = $_POST['httpref'];
    $httpagent = $_POST['httpagent'];
    $visitor = $_POST['visitor'];
    $notes = $_POST['notes'];
    $attn = $_POST['attn'];

    $todayis = date("l, F j, Y, g:i a");

    $attn = $attn ;
    $subject = $attn;

    $notes = stripcslashes($notes);

    $message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($Your Prayer or Concern)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

    $from = "From:\r\n";

    mail("", Prayers and Concerns, $message);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
<br />

Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="contact.php"> Next Page </a>
</p>
</body>
</html>

我遇到的困难是当它成功后我需要发送 $notes 但 $notes 始终为空。我应该将我的 sendmail php 放在我成功的 php 中吗?或者有人可以向我解释为什么 $notes 是空白的。

我确实输入了验证码,而且我也有一个电子邮件地址。我将一些内容保留为私有,我的 HTML 中还有一个注释文本区域

这是该表的 html:

<form action="doublecheck.php" action="http://www.ipower.com/scripts/formemail.bml" enctype="application/x-www-form-urlencoded" method="post">
  <table>
    <tbody style="font-size: 12px;">
      <tr>
        <td width="661">Your Prayer or Concern<br/>
          <textarea name="notes" rows="6" cols="100" maxlength="1024"></textarea></td>
      </tr>
      <tr>
        <td><script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LdoKLoSAAAAAChm6Oaquimz8g1elKd5OQBJtCLm"></script>

<noscript>
    <iframe src="http://api.recaptcha.net/noscript?k=6LdoKLoSAAAAAChm6Oaquimz8g1elKd5OQBJtCLm" height="300" width="500" frameborder="0"></iframe><br/>
    <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
    <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>                <p>
              <input type="submit" id="Pray" name="Pray" value="Send your prayer"/>
          </p></td>
      </tr>
      <tr>
      </tr>
    </tbody>

  </table>
</form>

Hey guys, if anybody can help me out i'd love it...

What i have is a form, that went sent, uses doublecheck.php

<?php  
    require_once('recaptchalib.php');  
    $privatekey = "";  
    $resp = recaptcha_check_answer ($privatekey,  
    $_SERVER["REMOTE_ADDR"],   
    $_POST["recaptcha_challenge_field"],  
    $_POST["recaptcha_response_field"]);  
    if (!$resp->is_valid) {  
        die ("Sorry please go back and try it again." .  
            "" . $resp->error . ")");  
    }  
    if ($resp->is_valid) {  
        require_once('sendmail.php');  
    }    
?>

And then my sendmail.php

<?php

    $ip = $_POST['ip'];
    $httpref = $_POST['httpref'];
    $httpagent = $_POST['httpagent'];
    $visitor = $_POST['visitor'];
    $notes = $_POST['notes'];
    $attn = $_POST['attn'];

    $todayis = date("l, F j, Y, g:i a");

    $attn = $attn ;
    $subject = $attn;

    $notes = stripcslashes($notes);

    $message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($Your Prayer or Concern)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

    $from = "From:\r\n";

    mail("", Prayers and Concerns, $message);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
<br />

Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="contact.php"> Next Page </a>
</p>
</body>
</html>

What i'm having a hard time with is when its succesful i need to send out $notes but $notes is always blank. Should i just put my sendmail php inside of my successful php? Or can someone explain to me why $notes is blank.

I do have my recaptcha key in, and also i do have an email address. I kept some things private, also there is a notes textarea in my HTML

Here is my html for that table:

<form action="doublecheck.php" action="http://www.ipower.com/scripts/formemail.bml" enctype="application/x-www-form-urlencoded" method="post">
  <table>
    <tbody style="font-size: 12px;">
      <tr>
        <td width="661">Your Prayer or Concern<br/>
          <textarea name="notes" rows="6" cols="100" maxlength="1024"></textarea></td>
      </tr>
      <tr>
        <td><script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LdoKLoSAAAAAChm6Oaquimz8g1elKd5OQBJtCLm"></script>

<noscript>
    <iframe src="http://api.recaptcha.net/noscript?k=6LdoKLoSAAAAAChm6Oaquimz8g1elKd5OQBJtCLm" height="300" width="500" frameborder="0"></iframe><br/>
    <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
    <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>                <p>
              <input type="submit" id="Pray" name="Pray" value="Send your prayer"/>
          </p></td>
      </tr>
      <tr>
      </tr>
    </tbody>

  </table>
</form>

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

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

发布评论

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

评论(1

猫瑾少女 2024-09-10 15:09:57

我建议您安装 Firefox 的 LiveHeaders 插件,并准确查看您提交的表单数据,以确保注释字段存在。如果是,则尝试使用 var_dump 转储 $_POST 数组并确保正确接收它。

Eclipse IDE 的 PHP 开发工具 插件有一个非常好的调试器。对于此类问题,在调试器中单步执行通常比添加一堆调试代码更容易。

I suggest you get the LiveHeaders plug in for Firefox and look at exactly what form data you're submitting to make sure that the notes field is there. If it is, then try using var_dump to dump the $_POST array and make sure that it's being received properly.

The PHP Development Tools plug in for the Eclipse IDE has a pretty good debugger. Stepping through in a debugger is usually easier for this kind of problem than adding a bunch of debugging code.

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