PHP contact form with nocaptca recaptcha

116 views Asked by At

Hello im very new to php and web development(well the server side of things anyway) in general i was hoping somebody could help me i cannot seem to get my php script to send emails here is my code

html file:

<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>

My PHP file:

<?php

    $email;$text;$comment;$Subject;$captcha;$text2;$message;
    $admin_email = "[email protected]";
    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>';
    }
?>

I really have no idea what i am doing wrong this is my first attempt at using PHP, any help would be greatly appreciated.

Update i checked my error log since changing php setting to display all errors and loads of errors like this poped up

[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

There are 0 answers