Trouble with Conact Form on website. Can anyone assist?

7 replies
Hello! I'm having trouble with the contact for in a website I'm developing.

The form is:

It's in html, I cant get it to forward the message to my email address.

Can anyone suggest something?

Also the page is in html and not php. Can this even be done in html?
#assist #conact #forum #trouble #website
  • Profile picture of the author mikeonrails
    It looks like you are using PHP in the form():
    <form id="contactform" method="post" action="send_contact.php">
    </form>

    The action says "send_contact.php".

    Your webpage is .html, but your form can still access a PHP file. You need to create a file on your server called "send_contact.php". In this file you will need to access each individual field element by using the $_POST variable. In the case of your form, you will need to use
    $_POST["subject"],$_POST["name"], etc...

    NOTE:
    If you want to send something purely via html, you can change the form action to action="mailto:you@yourdomainhere.com"
    You should never ever do this... it basically opens an email box on the viewer's computer(try it yourself). They would probably leave your site because they think it's a virus.
    {{ DiscussionBoard.errors[2763936].message }}
  • Profile picture of the author zeeshi570
    for sending mail in html you have to use mailto.
    That will open up outlook and can send mail.
    <button
    onclick="mailto:my@self.xyz?subject=hi&body=ha">
    send
    </button>

    use this code for send Message button
    {{ DiscussionBoard.errors[2767822].message }}
  • Profile picture of the author lknielsen
    Here's what I would do:

    Open the page on your webserver named "send_contact.php"

    Then paste the following code in that page below the code that's already in there:


    $subject = $_POST[subject];
    $name = $_POST[name];
    $customer_mail = $_POST[customer_mail];
    $detail = $_POST[detail];

    $to = "YOUR EMAIL GOES HERE";

    $body = "Name of Submitter: ";
    $body.= $name;
    $body.= "\n\n";
    $body.= "Message Detail: ";
    $body.= $detail;


    mail($to, $subject, $body),
    "From: $customer_mail\r\n"
    ."Reply-To: $customer_mail\r\n"
    ."X-Mailer: PHP/" . phpversion());


    Then edit the line above that says: $to = "YOUR EMAIL GOES HERE"; Just replace YOUR EMAIL GOES HERE with your actual email address.

    Hope this helps you!
    {{ DiscussionBoard.errors[2768782].message }}
  • Profile picture of the author icun
    You need a simple script to do this, PHP is easiest.

    Using "mailto:whatever@mail.com" is a big no, no.
    {{ DiscussionBoard.errors[2770276].message }}
  • Profile picture of the author RealSocialSignals
    Thanks people The problem is now solved, I had a problem with the send_contact.php which I fixed. But for some strange reason I receive 2 emails not 1.

    This is the send_contact.php code:
    ____________________________________________
    <?php

    if(isset($_POST['submit'])) {

    $to = "MY EMAIL";
    $subject = $_POST['subject'];
    $name_field = $_POST['name'];
    $email_field = $_POST['customer_mail'];
    $message = $_POST['detail'];

    $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

    mail($to, $subject, $body);

    die ("We've recived your contact information.");

    } else {

    echo "Error, please try again.";

    }
    ?>
    _________________________________________

    What am I doing wrong?
    {{ DiscussionBoard.errors[2770715].message }}
  • Profile picture of the author RealSocialSignals
    No one has a reply for me? Come on, it can't be that hard.
    {{ DiscussionBoard.errors[2771442].message }}
    • Profile picture of the author mikeonrails
      -Check to see if both emails are "received". Depending on your configuration, one of those emails might be a sent copy and the other is the mail you actually receive.

      -Check to see if the submit button is being clicked twice for some reason using javascript's alert() in the submit onclick handler of the button.

      -Switch your echo and die statements. Die is an indication of failure, not success:

      echo "We've received your contact information." ;
      die("Error, please try again.");
      {{ DiscussionBoard.errors[2771804].message }}

Trending Topics