Forums Get help. Give help.

Simple Contact form
  • lanawylmalanawylma February 20
    Hi All,

    I downloaded Chris's simple contact form, and, since I know pretty much nothing about PHP, I was hoping to get some help..

    Below is my markup:


    <form id="contact-form" action = "contactengine.php" method = "post">

    <fieldset id="texfields" class="grid_4 alpha">
    <ul>
    <li>
    <label for="name">Name</label><br>
    <input id="name" name="name" type="text" placeholder="First and last name" required>

    </li>

    <li>
    <label for="email">Email</label><br>
    <input id="email" name="email" type="email" placeholder="example@domain.com" required>


    </li>

    <li>
    <label for="phone">Phone</label><br>
    <input id="phone" name="phone" type="tel" placeholder="Eg.000.000.0000" required>
    </li>
    </ul>

    </fieldset>

    <fieldset id="comments" class="grid_4 omega">

    <label for="comments">Comments</label><br>
    <textarea id="comments" name="comments" placeholder="Type your message here"required></textarea><br>

    <button type="submit" class="grid_1">Send</button>

    </fieldset>



    </form>



    And this is the PHP that I modified (I was hoping that's what I had to do) to match my markup:

    <?php

    $EmailFrom = "chriscoyier@gmail.com";
    $EmailTo = "info@dreamgem.net";
    $Subject = "Nice & Simple Contact Form by CSS-Tricks";
    $Name = Trim(stripslashes($_POST['name']));
    $Email = Trim(stripslashes($_POST['email']));
    $Phone = Trim(stripslashes($_POST['phone']));
    $Comments = Trim(stripslashes($_POST['comments']));

    // validation
    $validationOK=true;
    if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    exit;
    }

    // prepare email body text
    $Body = "";
    $Body .= "name: ";
    $Body .= $name;
    $Body .= "\n";
    $Body .= "email: ";
    $Body .= $email;
    $Body .= "\n";
    $Body .= "phone: ";
    $Body .= $phone;
    $Body .= "\n";
    $Body .= "comments: ";
    $Body .= $comments;
    $Body .= "\n";

    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

    // redirect to success page
    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
    }
    else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>


    My issues are:

    1. I receive the email, but the content is empty
    2. How do I modify the From field so that it would show actual email it came from instead of static email I set..
    3. I would like to get rid of the re-direct page as I'm using this form on the footer of a website..

    Thanks a bunch in advance and sorry for very basic question!

  • MegaMikeMegaMike February 20
    I'm having the same issue with an empty email.. I get the template printed, but the user input is not printed in the email.
  • TT_MarkTT_Mark February 22
    1)
    Think about what you're doing.

    $Email and $email are not the same. PHP variables are case sensitive.

    3) Remove the print which redirects to contactthanks.php



Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

Tips

Just some helpful hints to get the most out of the forums.