Jump to content


Photo
- - - - -

Contact Form Help


Best Answer danbingham, 20 March 2017 - 06:25 PM

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"); 
?>
Go to the full post


  • Please log in to reply
3 replies to this topic

#1 danbingham

danbingham

    Forum Newcomer

  • Members
  • Pip
  • 19 posts

Posted 20 March 2017 - 04:08 PM

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();
}
?>


#2 danbingham

danbingham

    Forum Newcomer

  • Members
  • Pip
  • 19 posts

Posted 20 March 2017 - 04:11 PM

You can see the form here - http://drivingsupercars.com/



#3 TimW

TimW

    Advanced Member

  • Members
  • PipPipPip
  • 259 posts
  • Gender:Male
  • Location:West Country
  • Experience:Intermediate
  • Area of Expertise:Nothing

Posted 20 March 2017 - 05:58 PM

Beyond simple is this:

https://formspree.io/

3 lines of html and it just works. No more messing with contact forms.

I keep thinking there must be a catch


Edited by TimW, 20 March 2017 - 05:59 PM.


#4 danbingham

danbingham

    Forum Newcomer

  • Members
  • Pip
  • 19 posts

Posted 20 March 2017 - 06:25 PM   Best Answer

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"); 
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users