form to email not delivering

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
struggling
Forum Newbie
Posts: 4
Joined: Thu Feb 11, 2010 5:10 am

form to email not delivering

Post by struggling »

I have a contact form to email php that is not working!
It directs to the thankyou page as if it has worked and sends the client a thankyou email saying we will be in touch - only we wont because it hasn't actually sent us the information!!
No e-mail is recieved by us at all??!!
Please can anyone help me? I don't know what I'm doing wrong!!


Here is the PHP Code:

Code: Select all

 
 
 
<?php
 
$to = "admin@domain.com" ;
 
$from = $_REQUEST['email'] ;
 
$name = $_REQUEST['name'] ;
 
$headers = "From: $from" ;
 
$subject = "Contact Form Data" ;
 
 
$fields = array();
 
$fields{"name"} = "Name" ;
 
$fields{"email"} = "Email" ;
 
$fields{"telephone"} = "Telephone" ;
 
$fields{"town"} = "Town" ;
 
$fields{"breed"} = "Breed" ;
 
$fields{"trainingclasses"} = "Interested In Training Classes?" ;
 
$fields{"kennelclubscheme"} = "Interested In kennel Club Scheme?" ;
 
$fields{"agility"} = "Interested In Agility?" ;
 
$fields{"behaviourconsultation"} = "Interested In Behaviour Consultation?" ;
 
$fields{"dogprofiling"} = "Interested In Dog Profiling?" ;
 
$fields{"raf"} = "Interested in RAF?" ;
 
$fields{"message"} = "Message" ;
 
 
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 
 
$headers2 = "From: admin@domain.com"; 
 
$subject2 = "Thank you for contacting us"; 
 
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usually within 48 hours. If you have any more questions, please consult our website at http://www.domain.com";
 
if($from == '') {print "You have not entered an email, please go back and try again";} 
 
else {
 
if($name == '') {print "You have not entered a name, please go back and try again";} 
 
else { 
 
$send = mail($to, $subject, $body, $headers); 
 
$send2 = mail($from, $subject2, $autoreply, $headers2); 
 
if($send) 
 
{header( "Location: http://www.domain.com/thankyou.html" );} 
 
else 
{print "We encountered an error sending your mail, please notify webmaster@domain.com"; } 
 
}
 
}
 
?> 
 
 
 
struggling
Forum Newbie
Posts: 4
Joined: Thu Feb 11, 2010 5:10 am

Re: form to email not delivering

Post by struggling »

here is the code for the html form
(I have removed most of the options in the dropdown lists leaving just a few in each as there were millions!! otherwise left intact)

Code: Select all

 
<form action="contactsendmail.php" method="post">
    
    <fieldset>
    <ol>
    <li>    
        <br />
        <br />
        <label for="name">Name</label>
        <input id="name" name="name" type="text" size="31" />
    </li>
    <li>
        <label for="email">Email</label>
        <input id="email" name="email" type="text" size="31" />
    </li>
    <li>
        <label for="telephone">Telephone</label>
        <input id="telephone" name="telephone" type="text" size="31" />
    </li>
    <li>
        <label for="town">Town</label>
        <select name="town" style="width:222px">
            <option value="blank"></option>
            <option value="Abram">Abram</option>
            <option value="Accrington">Accrington</option>
            <option value="Acton Bridge">Acton Bridge</option>
            
        </select>
    </li>
    <li>
        <label for="dogbreed">Dog Breed</label>
        <select name="breed" cols="25">
            <option value="blank"></option>
            <option value="Affenpinscher">Affenpinscher</option>
            <option value="Afghan Hound">Afghan Hound</option>
            <option value="Airedale Terrier">Airedale Terrier</option>
        </select>
    </li>
    <li>
    <fieldset id="boxes">
    <legend>I am Interested in</legend>
    <ol>
    <li>    
        <input type="checkbox" name="trainingclasses" value="yes" />
        <label for="trainingclasses">Training Classes</label>
    </li>
    <li>
        <input type="checkbox" name="kennelclubscheme" value="yes" />
        <label for="kennelclubscheme">Kennel Club Scheme</label>
    </li>
    <li>
        <input type="checkbox" name="agility" value="yes" />
        <label for="agility">Agility</label>
    </li>
    <li>
        <input type="checkbox" name="behaviourconsultation" value="yes" />
        <label for="behaviourconsultation">Behaviour Consultation</label>
    </li>
    <li>
        <input type="checkbox" name="dogprofiling" value="yes" />
        <label for="dogprofiling">Dog Profiling</label>
    </li>
    <li>
        <input type="checkbox" name="raf" value="yes" />
        <label for="raf">RAF</label>
    </li>
    </ol>
    </fieldset>
    
    <li>
        <label for"message">Message</label>
        <textarea name="message" rows="3" cols="25"></textarea>
    </li>
    </fieldset>
    <fieldset id="submit">
    <li>
        <input type="submit" value="Submit" />
    </li>
    </ol>
    </fieldset>
    
</form>
Post Reply