Help with contact form not sending data

Hi everyone, can you please have a look at http://www.sntravel.co.uk/contact-us.php and figure out what’s the problem here?

I’m using this send.php that I’ve got for the form:

<?php
$name = $_POST['name'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$newsletter = $_POST['newsletter'];
   	
$toaddress = "********@gmail.com";
$subject = "Request Information";
$msg = "$name\
";
$msg.= "$phone\
";
$msg.= "$message\
";
$msg.= "$newsletter\
";


$mailheaders = "From: $email\\r\
";
$mailheaders .= "To: ********@gmail.com\\r\
";
$mailheaders .= "Content-Type: multipart/mixed\\r\
";
mail("$toaddress", "$subject", "$msg", "$mailheaders");
		
		  //To redirect form on a particular page
		   echo header("Location:/thanks.html");
		
?>

but it won’t send to my e-mail.

Also the recaptcha is there but it’s not mandatory as I can press send without it even doing anything.

EDIT
This post has been reformatted by enclosing the code block in 3 backticks
```
on their own lines.

Define DOMAIN email address.

<?php
//Define Domain email address
$email = "info@mydomain.com";

$name = $_POST['name'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$newsletter = $_POST['newsletter'];
       
$toaddress = "********@gmail.com";
$subject = "Request Information";
$msg = "Name: " . $name . "\r\n";
$msg .= "Phone: " . $phone . "\r\n\r\n";
$msg .= $message . "\r\n\r\n";
$msg .= $newsletter;


$mailheaders = "From: " . $email . "\r\n";
$mailheaders .= "Content-Type: multipart/mixed\r\n";

mail($toaddress, $subject, $msg, $mailheaders);
        
    //To redirect form on a particular page
    header("Location: /thanks.html");
    exit;
        
?>

Hi thanks for your reply.

I get an empty email with that php code with a noname file with no extension attached.

Also the captcha is not stopping the form from sending if I don’t input

I would remove that header line as it’s not needed.

$mailheaders .= "Content-Type: multipart/mixed\r\n";

As you’ve not provided form code or post processing code, no one can help you with the captcha

Hi Drummin, thanks. Where is this code? I only have a link href pointing to the recaptcha as google suggested and the html div calling the captcha.
THe sourcecode is on the page ofc. Can you advise please?

I’ve never used Google recaptcha. Did you download the recaptchalib.php file. Have the JS and iframe sections added and the suggested code added to your php form page?

require_once('recaptchalib.php');
  $publickey = "YOUR_PUBLIC_KEY"; // You got this from the signup page.
  echo recaptcha_get_html($publickey);

Again, I have not used it but it looks like pretty good directions.
https://code.google.com/p/recaptcha/wiki/HowToSetUpRecaptcha#PHP

That site looks really different from mine.

I’m missing this part:

When your users submit the form where you integrated reCAPTCHA, you’ll get as part of the payload a string with the name “g-recaptcha-response”. In order to check whether Google has verified that user, send a GET request with these parameters:
URL: https://www.google.com/recaptcha/api/siteverify
secret(required) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
response(required) The value of ‘g-recaptcha-response’.
remoteip The end user’s ip address.

Well again, I don’t have the code.

What do they provide to you? It appears you send a get requests (probably with JS) and it returns a true,false reply.
Do you get examples of how to implement their code?

Beside the link I posted above (which looks like the same “Product”), this site also has good info
https://developers.google.com/recaptcha/

I don’t know what code you are referring to sorry. Only code i’ve got is the , js and php. First 2 are in the page, the php I’ve posted earlier.

This link has a zip file containing required files and a sample of how to implement the latest version of recaptcha.
https://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.