Jump to content
Sign in to follow this  
danbingham

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.

 

<?php
/* 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:
$offerinquiry
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');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>

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 -

 

<?php
$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
      57,553
    • Most Online
      4,970

    Newest Member
    Skilton06
    Joined
  • Forum Statistics

    • Total Topics
      65,740
    • Total Posts
      455,352
×