PHP联系表格与nocaptca recaptcha

时间:2015-06-22 23:07:23

标签: php html recaptcha contact-form

你好我非常新的php和web开发(好吧服务器方面的东西无论如何)一般我希望有人可以帮助我我似乎无法让我的PHP脚本发送电子邮件在这里是我的代码

html文件:

<form id="comment_form" action="form.php" method="post">
                <input type="name" class="bx" size="40"><br/>
                <input type="text" placeholder="Name" class="txtboxes" size="40"><br/>
                <input type="email" placeholder="Type your email" class="txtboxes" size="40"><br/>
                <input type="Subject" placeholder="Subject" class="txtboxes" size="40"><br/>
                <textarea name="comment" rows="8" class="txtboxes" cols="42"></textarea><br/>
                <div class="g-recaptcha btns" data-sitekey="6LdpqQgTAAAAAG8d57RTmnC-wzwRBRJuGx0ir8jT"></div>
                <input type="submit" class="btns" name="submit" value="Send"><br><br>
            </form>

我的PHP文件:

<?php

    $email;$text;$comment;$Subject;$captcha;$text2;$message;
    $admin_email = "support@myemail.com";
    if(isset($_POST['email']) && !empty($_POST['email'])){
      $email=$_POST['email'];
    }
    if(isset($_POST['text']) && !empty($_POST['text'])){
        $text=$_POST["text"];
    }
    if(isset($_POST['Subject']) && !empty($_POST['Subject'])){
        $Subject=$_POST["Subject"];
    }
    if(isset($_POST['comment']) && !empty($_POST['comment'])){
      $comment=$_POST['comment'];
    }if(isset($_POST['g-recaptcha-response'])){
      $captcha=$_POST['g-recaptcha-response'];
    }
    if(!empty($_POST['text2'])){
        echo '<h2>testing.</h2>';
        exit;
    }
    if(!$captcha){
      echo '<h2>Please check the the captcha form.</h2>';
      exit;
    }
    $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret="secret key taken out "&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
    if($response.success==false)
    {
      echo '<h2>response for spammers</h2>';
    }else
    {
        $message = "Name:" $text . ". User Comment:" . $comment; 
        mail($admin_email, $Subject, $message, $email);
      echo '<h2>Thanks for contacting us we will get back to you as soon as possible.</h2>';
    }
?>

我真的不知道我做错了这是我第一次尝试使用PHP,任何帮助都会非常感激。

更新 我检查了我的错误日志,因为更改了php设置以显示所有错误和错误加载

[2015-06-23 13:58:08] [core:warn] [client 109.79.49.67:32896] AH02296: Unknown directive error_reporting(e_all); perhaps misspelled or defined by a module not included in the server configuration, referer http://star-gaming.co.uk/ContactUs.html

[2015-06-23 13:58:08] [core:warn] [client 109.79.49.67:32896] AH02296: Unknown directive ini_set('display_errors', perhaps misspelled or defined by a module not included in the server configuration, referer http://star-gaming.co.uk/ContactUs.html

0 个答案:

没有答案