Jump to content


Photo

Form not sending to Email


  • Please log in to reply
1 reply to this topic

#1 vickyjackson

vickyjackson
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 20 March 2006 - 12:27 PM

Hi,

I'm really having problems with my form - I've been trying to get this to work for hours & hours & can't work out what is wrong with it. Below I have pasted the form code & the php code. When the form is submitted I can't see any mention at the bottom of the window to mail, just straight away says finding page 'thankyou.php'. Thankyou page loads with the 'name' element which I added to the URL.

If anyone can shed any light on this I would appreciate it soo much.

Thanks, Vicky

<FORM CODE>
<form name="form1" method="post" action="Contactform.php">
<table width="95%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td width="34%"><font face="Arial, Helvetica, sans-serif">Name:</font></td>
<td width="66%"><font face="Arial, Helvetica, sans-serif">
<input name="name" type="text" id="name" size="40" maxlength="40">
</font></td>
</tr>
<tr>
<td> <p><font face="Arial, Helvetica, sans-serif">E-Mail:</font></p></td>
<td><font face="Arial, Helvetica, sans-serif">
<input name="email" type="text" id="email" size="40" maxlength="40">
</font></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif">Phone:</font></td>
<td><input name="phone" type="text" id="phone" size="30" maxlength="30"></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif">Address:</font></td>
<td><textarea name="address" cols="30" rows="4" id="address"></textarea></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif">I am interested in: </font></td>
<td><select name="option" id="option">
<option value="Unsure">I'm Not Sure</option>
<option value="Mini Package">Mini</option>
<option value="Standard Package">Standard</option>
<option value="Advanced Package">Advanced</option>
</select></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif">Message:</font></td>
<td><font face="Arial, Helvetica, sans-serif">
<textarea name="com" cols="40" rows="8" id="com"></textarea>
</font></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
<td><font face="Arial, Helvetica, sans-serif">
<input name="Submit" type="submit" id="Submit" value="Submit">
<input name="Reset" type="reset" id="Reset" value="Reset">
</font></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
PHP_____________________________________________________________________________________

<?
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$address = $_POST["address"];
$site = $_POST["site"];
$com = $_POST["com"];
$today = date("d, M Y");
$recipient = "vicky@something.co.uk";
$subject = "Enquiry from the Website";
$forminfo ="Name: $name\nEmail: $email\nPhone: $phone\nAddress: $address\nInterested in: $site\nMessage: $com\nForm Submitted: $today\n\n";

$sent = mail($recipient, $subject, $forminfo, "From: $email");
if($sent)
{
header("Location: [a href=\"http://www.something.co.uk/thankyou.php?name=$_POST\" target=\"_blank\"]http://www.something.co.uk/thankyou.php?name=$_POST[/a][name]");}
else
{
echo 'Sorry, your message could not be sent at this time. Please try again or email us directly.';
}
?>

#2 Humpty

Humpty
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts

Posted 21 March 2006 - 06:30 AM

You seem unresponded to so far so I'm gonna but in and add a reply.

Just at a quick glance it all looks fine to me except the FROM in the mail command.

That could be the prob. Some servers have issues if it isn't done properely.

This has worked for me on many occassions and if you know what all the from details are you could condence it and remove 2 lines.

            $uToAddress="username@domain.com";
            //E.G. customer@hotmail.com or if sending to yourself siteadmin@mysite.com

            $uSubject="This is the subject of the email";
            //Self explanatory
            
            $mystr="This is the body of the email";
            //Self explanatory
            
            $frmName="This is the From Name";
            // E.G Site Admin
            $frmEmail="This_is_the_Reply@email_Address"; 
            // E.G siteadmin@mysite.com
            
            $uFromWho = "From:$frmName\r\nReply-to: $frmEmail\r\nX-Mailer: PHP/" . phpversion(); 
            //Only part here I understand is where to put the name and email address for
            //the FROM field of the email.



            mail($uToAddress, $uSubject, $mystr, $uFromWho)
            //mail(TO, SUBJECT, BODY, FROM)

- Humpty
  #> Where does the light go when it goes out?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users