Jump to content
Sign in to follow this  

Contact Form Help

Recommended Posts

Hi Folks,


I am having some issues in getting our form to work, and I am hoping someone can help. I have used a customised script which I have altered but am still experiencing issues in getting the form to work once a user clicks on 'send message' button.

Is there a simple script i can upload and change, or is there something I need to change to the existing script - see below. Any help or advice would be appreciated.


/* Set e-mail recipient */
$myemail = "dan@definitelydomains.com";
/* Check all form inputs using check_input function */
$name = check_input($_POST['Name']);
$email = check_input($_POST['Email']);
$offerinquiry = check_input($_POST['Offer Inquiry']);
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
show_error("E-mail address not valid");
/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
$website = '';
/* Let's prepare the message for the e-mail */
$message = "Hello!
Your contact form has been submitted by:
Name: $name
E-mail: $email
Offer Inqury:
End of message
/* Send the message using mail() function */
mail($myemail, $name, $email $offerinquiry);
/* Redirect visitor to the thank you page */
header('Location: thanks.htm');
/* Functions we used */
function check_input($data, $problem='')
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
return $data;
function show_error($myError)
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>

Share this post

Link to post
Share on other sites

Thank you - I will check this out.


I have added a simple script in the meantime which seems to have worked to a degree. I am now able to receive the email once someone hits 'Send message', but how do i alter this script to include additional comments? The amended script i am using is below -


$ToEmail = 'dan@definitelydomains.com';
$EmailSubject = 'DrivingSupercars';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."";
$MESSAGE_BODY .= "Offer Inquiry: ".nl2br($_POST["offer_inquiry"])."";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing

    No registered users viewing this page.

  • Member Statistics

    • Total Members
    • Most Online

    Newest Member
  • Forum Statistics

    • Total Topics
    • Total Posts