Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Chris Coyier Simple Contact Form

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #24109
    lindaph
    Member

    Hi Guys

    I’ve just downloaded Chris’s very simple contact form and the requisite parts to it. It seems to be working …. BUT I’m not getting the emails through.

    I think I must be missing something really simple here but for the life of me can’t work out what it is. I have added the code for the contact engine below:-


    <?php

    $EmailFrom = "[email protected]";
    $EmailTo = "[email protected]";
    $Subject = "Enquiry From PGD";
    $Name = Trim(stripslashes($_POST));
    $Company = Trim(stripslashes($_POST));
    $Email = Trim(stripslashes($_POST));
    $Tel = Trim(stripslashes($_POST));
    $Address1 = Trim(stripslashes($_POST));
    $Address2 = Trim(stripslashes($_POST));
    $Address3 = Trim(stripslashes($_POST));
    $Postcode = Trim(stripslashes($_POST));
    $Interest = Trim(stripslashes($_POST));
    $EmailPlease = Trim(stripslashes($_POST));
    $PhonePlease = Trim(stripslashes($_POST));
    $Message = Trim(stripslashes($_POST));

    // 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 .= "Company: ";
    $Body .= $Company;
    $Body .= "n";
    $Body .= "Email: ";
    $Body .= $Email;
    $Body .= "n";
    $Body .= "Tel: ";
    $Body .= $Tel;
    $Body .= "n";
    $Body .= "Address1: ";
    $Body .= $Address1;
    $Body .= "n";
    $Body .= "Address2: ";
    $Body .= $Address2;
    $Body .= "n";
    $Body .= "Address3: ";
    $Body .= $Address3;
    $Body .= "n";
    $Body .= "Postcode: ";
    $Body .= $Postcode;
    $Body .= "n";
    $Body .= "Interest: ";
    $Body .= $Interest;
    $Body .= "n";
    $Body .= "EmailPlease: ";
    $Body .= $EmailPlease;
    $Body .= "n";
    $Body .= "PhonePlease: ";
    $Body .= $PhonePlease;
    $Body .= "n";
    $Body .= "Message: ";
    $Body .= $Message;
    $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">";
    }
    ?>



    The code for the htm page is below too:


    <form method="post" action="contactengine.php">
    <table cellspacing="0" cellpadding="0" id="ContactTable">
    <tr>
    <td class="FormQuestion">Name:</td>
    <td class="FormAnswer"><input type="text" name="Name" /></td>
    </tr>
    <tr>
    <td class="FormQuestion">Company:</td>
    <td class="FormAnswer"><input type="text" name="Company" /></td>
    </tr>
    <tr>
    <td class="FormQuestion">Email:</td>
    <td class="FormAnswer"><input type="text" name="Email" /></td>
    </tr>
    <tr>
    <td class="FormQuestion">Phone:</td>
    <td class="FormAnswer"><input type="text" name="Tel" /></td>
    </tr>
    <tr>
    <td class="FormQuestion">Address:</td>
    <td class="FormAnswer"><input type="text" name="Address1" /></td>
    </tr>
    <tr>
    <td class="FormQuestion">&nbsp;</td>
    <td class="FormAnswer"><input type="text" name="Address2" /></td>
    </tr>
    <tr>
    <td class="FormQuestion">&nbsp;</td>
    <td class="FormAnswer"><input type="text" name="Address3" /></td>
    </tr>
    <tr>
    <td class="FormQuestion">Postcode:</td>
    <td class="FormAnswer"><input type="text" name="Postcode" /></td>
    </tr>
    <tr>
    <td class="FormQuestion">I’m interested in: </td>
    <td class="FormAnswer">
    <select name="Interest">
    <option>mugs</option>
    <option>clothing</option>
    <option>pens</option>
    <option>promotional gifts</option>
    </select></td>
    </tr>
    <tr>
    <td class="FormQuestion">How would you like us to contact you?
    </td>
    <td class="FormAnswer"><input name="EmailPlease" id="EmailPlease" type="checkbox" value="Phone" />
    <label for="EmailPlease">email</label><br />
    <input name="PhonePlease" id="PhonePlease" type="checkbox" value="Phone" />
    <label for="PhonePlease">telephone</label></td>
    </tr>
    <tr>
    <td class="FormQuestion" valign="top">Comments:</td>
    <td class="FormAnswer"><textarea name="Message" cols="25" rows="5">please type your enquiry here</textarea></td>
    </tr>
    <tr class="FormButtonRow">
    <td align="center"><input class="FormButton" type="reset" name="Reset" value="Reset" /></td>
    <td align="center"><input class="FormButton" type="submit" name="Send" value="Submit" /></td>
    </tr>
    </table>
    </form>



    I get no error messages at all, just no emails to speak of.

    Was wondering though whether I need to add something in that points the contactengine at a sendmail programme of some description or whether this is all I need and if so why the emails aren’t getting through.

    Any help would be greatly appreciated.

    Linda

    #53722

    You may want to double check with your host that they support PHP’s mail() function that sends the email. For example, if you are hosting through GoDaddy, they disable mail() and ask you to use a premade contact script.

    #53747
    ikthius
    Member

    if your site is on a windows server, you may have to set your ini file
    ini_set("sendmail_from", "someemailhandleraddress");

    this should be the next line of code after opening your php

    #53716
    lindaph
    Member

    Hi Guys

    Thanks for this. I did try the forms out on two different servers and eventually received the form data through from one of them, but it took 12 hours to arrive!

    I have gone back to the hosts of the main site to see if they support the php () mail function to check that this isn’t the problem.

    #53783
    ikthius
    Member

    Lindaph,

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

    should this not be:
    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$Email>");

    as you want to get the email from the person???

    EmailTo is your email cause this is getting sent to you
    Email in your declaration is the person filling in the form, so should this not be the From: ??

    just saying cause thats how I have my script

    also: is your path to the contact script correct? have you got your contact script in your cgi-bin, cause your action does not say it is, you may be pointing to nothing

    and check your email program is not filtering out any emails

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.