Jump to content

Contact Form


stublackett

Recommended Posts

Hi,

 

I've made a contact form, The E-Mail address that the form sends to is valid etc, But its just not sending to my E-Mail address

 

The HTML code is

<form method="post" action="contact.php" >  
                                        <fieldset>
                                        <legend>Contact Details</legend>  
                                        <ol>  
                                        <li>  
                                        <label for="name">Name :</label>  
                                        <input name="name" type="text" class="text" id="name" size="35" />  
                                        </li>  
                                        <li>  
                                        <label for="email">Email address :</label>  
                                        <input name="email" type="text" class="text" id="email" size="35" />  
                                        </li>  
                                        <li>  
                                        <label for="phone">Telephone Number :</label>  
                                        <input name="phone" type="text" class="text" id="phone" size="35" />  
                                        </li>
                                        <li>  
                                        <label for="fax">Fax Number :</label>  
                                        <input name="fax" type="text" class="text" id="fax" size="35" />  
                                        </li>
                                        <li>  
                                        <label for="address1">Address Line 1 :</label>  
                                        <input name="address" type="text" class="text" id="address1" size="35" />  
                                        </li>
                                        <li>  
                                        <label for="address2">Address Line 2 :</label>  
                                        <input name="address2" type="text" class="text" id="address2" size="35" />  
                                        </li>
                                        <li>  
                                        <label for="postcode">Post Code:</label>  
                                        <input name="postcode" type="text" class="text" id="postcode" size="35" />  
                                        </li>
                                        <li>
                                        <label for="yourmessage">Your Message : </label>
                                        <textarea name="message" cols="33" rows="5" class="text" id="message"></textarea></ol>  
                                        </fieldset>  
                                        <fieldset class="submit">  
                                        <input class="submit" type="submit"  
                                        value="Submit" />  
                                        <input class="reset" type="reset" />
                                        </fieldset> 
                                        </form>

 

and the PHP That handles that form is

 

<?php

$to = "[email protected]";
$subject = "Alnwick Lodge Contact E-Mail";
$name = $_POST["name"];
$email = $_POST["email"];
$telephone = $_POST["phone"];
$fax = $_POST["fax"];
$address1 = $_POST["address"];
$address2 = $_POST["address2"];
$postcode = $_POST["postcode"];
$message = $_POST["message"];


$messagesent = "From: $name Message: $message";
$from = $_POST["email"];
$headers = "From: $from";
mail($to,$subject,$messagesent,$headers);
echo "Your message has been sent to the webmaster, thank you.";

?>

 

Can anyone see any reason why this isnt working?  ???  ???

Link to comment
https://forums.phpfreaks.com/topic/108530-contact-form/
Share on other sites

mail() returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

 

your echo will be shown in any case (except there is an syntax error...). change your echo to this:

 

$result = mail($to,$subject,$messagesent,$headers);
if($result){
    echo "Your message has been sent to the webmaster, thank you.";
}

 

edit: also check if your variables are not empty before you send the mail.

Link to comment
https://forums.phpfreaks.com/topic/108530-contact-form/#findComment-556479
Share on other sites

mail() returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

 

your echo will be shown in any case (except there is an syntax error...). change your echo to this:

 

$result = mail($to,$subject,$messagesent,$headers);
if($result){
    echo "Your message has been sent to the webmaster, thank you.";
}

 

edit: also check if your variables are not empty before you send the mail.

 

Still no joy with that, I'm afraid

 

I've echoed out the variables to see if their sending over and they definatley are, It just seems that its that mail function thats not doing the job

 

Unless I all of a sudden get 6 or 7 e-mails from trying

Link to comment
https://forums.phpfreaks.com/topic/108530-contact-form/#findComment-556484
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.