Getting "error" with a basic PHP contact form

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Re: Getting "error" with a basic PHP contact form

Post by simplypixie » Sat Dec 22, 2012 12:33 am

When you send data from a form, you need to use $_POST['name'] to get the data that has been submitted, so in your case you need:

Code: Select all

<?php

// Contact subject
$subject =$_POST['subject'];

// Details
$message=$_POST['detail'];


// Mail of sender
$mail_from=$_POST['customer_mail'];

// From
$header="from: $_POST['name'] <$mail_from>";


// Enter your email address
$to ='myname@mydomain.com';

$send_contact=mail($to,$subject,$message,$header);


// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests