PDA

View Full Version : php form mail problem


jeremyb
07-16-2003, 07:31 PM
I am having a problem with an online questions or comment form, hopefully someone here can help me out. The strange this here is that on one php server the form works fine and on another php server the form processes the information fine but the email is never received displaying the content. Now, I am not 100% sure but I think the two different server are running two different version of php. Here is a copy of my code.
__________________________________________
questions.php
__________________________________________
<body bgcolor="#E0E0E0">
<div align="center"><img src="images/title.gif" width="750" height="50"> <br>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="158" align="left" valign="top"><?php include("nav.php"); ?></td>
<td valign="top"> <div align="center">
<table width="580" border="1" align="right" cellpadding="7" cellspacing="0" bordercolor="#000066" bgcolor="#FFFFFF">
<tr>
<td><div align="left">
<table width="100%" border="1" cellpadding="3" bordercolor="#000066">
<tr bgcolor="#999999">
<td><div align="center"><font color="#FFFFFF" size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong>Questions
or Comments</strong></font></div></td>
</tr>
<tr bgcolor="#999999">
<td width="100%" bgcolor="#FFFFFF">
<div align="center">
<p><font color="#000066" size="3" face="Verdana, Arial, Helvetica, sans-serif">Please
fill out the following online form locate below<br>
and will get back with you shortly.<br>
<font color="#FF0000" size="2">* means required field</font></font></p>
<form method="post" action="sendquestions.php">
<div align="justify">
<p> Name:
<input name="name" type="text" id="name" size="45">
<font color="#FF0000">*</font><br>
<br>
Address:
<input name="address" type="text" id="address" size="45">
<br>
<br>
City:
<input name="city" type="text" id="city">
&nbsp;&nbsp;State:
<input name="state" type="text" id="state" size="5">
&nbsp;&nbsp;Zip:
<input name="zip" type="text" id="zip" size="10">
<br>
<br>
Phone:
<input name="phone" type="text" id="phone">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fax:
<input name="fax" type="text" id="fax">
<br>
<br>
Email:
<input name="email" type="text" id="email" size="70">
<font color="#FF0000">*</font></p>

</div>
<p>How would you like to be contacted:<font color="#000066" size="3" face="Verdana, Arial, Helvetica, sans-serif">
<select name="contact" id="contact">
<option value="Select One" selected>Select One</option>
<option value="Phone">Phone</option>
<option value="Fax">Fax</option>
<option value="Email">Email</option>
</select>
<font color="#FF0000">*</font><br>
<br>
</font><font color="#000000" size="3">Question or
Comment:</font><font color="#000066" size="3" face="Verdana, Arial, Helvetica, sans-serif"><br>
<br>
<textarea name="question" cols="60" rows="10" id="question"></textarea>
</font> <font color="#FF0000">*</font><font color="#000066" size="3" face="Verdana, Arial, Helvetica, sans-serif"><br>
<br>
<input type="submit" name="Submit" value="Submit">
<br>
</font></p>
</form>

<p>&nbsp;</p>
</div></td>
</tr>
</table>
<br>
</div>
</td>
</tr>
</table>
</div>
<br> <div align="center"></div></td>
</tr>
</table>
</div>
</body>
___________________________________________________
sendquestions.php
___________________________________________________
<body bgcolor="#E0E0E0">
<div align="center"><img src="images/title.gif" width="750" height="50"> <br>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="158" align="left" valign="top"><?php include("nav.php"); ?><br>
<div align="center"></div></td>
<td valign="top"> <div align="center">
<table width="580" border="1" align="right" cellpadding="7" cellspacing="0" bordercolor="#000066" bgcolor="#FFFFFF">
<tr>
<td> <p align="center"><font size="2">
<?
$dufrene = "Dufrene Building Materials";
$dufreneemail = "jeremyb@mobiletel.com";
if (($name == "") or ($email == "") or ($contact == "") or ($question == ""))
{
print ("The following fields need to be filled out before the form can be sent:<br>
Name, Email, Contact, and Question or Comment.
<br>Please hit the back key on your browser and
make sure that these fields are filled in. Thank You!");
} else {
print ("<font face=\"Arial, Helvetica, sans-serif\" color=\"#336699\">Thank you $name for
submitting a a question or comment. Someone will contact you shortly.</font></font>");

mail(
"jeremyb@mobiletel.com",
"Question or Comment from website",
"Name: $name

Address: $address
City: $city
State: $state
Zip: $zip

Phone: $phone
Fax: $fax

Email: $email

Please contact me by: $contact

Question or Comment: $question
",
"From: ".$customer." <".$email.">\nX-Mailer: PHP/" . phpversion());

mail(
"$email",
"Questions or Comments Auto response",
"Thank you for submitting a question or comment. Someone will contact you shortly.
You submitted the following
Name: $name

Address: $address
City: $city
State: $state<br>
Zip: $zip

Phone: $phone
Fax: $fax

Email: $email

Please contact me by: $contact

Question or Comment: $question
",
"From: ".$dufrene." <".$dufreneemail.">\nX-Mailer: PHP/" . phpversion());

?>
</font></p>
<font size="2">
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td> <div align="center">
<p><font face="Arial, Helvetica, sans-serif" size="2" color="#336699">You
submitted the following information:</font></p>
<p align="center"><font face="Arial, Helvetica, sans-serif" size="2" color="#336699"><?echo "$name";?><br>
<?echo "$address";?><br>
<?echo "$city, $state $zip";?><br>
<?echo "$phone";?><br>
<?echo "$fax";?><br>
<?echo "$email";?><br><br>
<?echo "$question";?><br>
</font></div></td>
</tr>
</table>
<?
}
?>
</font>
<div align="left"><br>
</div>
</td>
</tr>
</table>
</div>
<br> <div align="center"></div></td>
</tr>
</table>
</div>
</body>
_________________________________________________
any help would be greatly appreciated.

Thanks,
Jeremy Blanchard
jeremyb@ndanet.com

Jason
07-17-2003, 12:30 AM
ok, that second form, the one actually written in PHP is the one that sends the email to the user. Now, the problem you have is that there is probably a cron job that executes that file and it might only be on that one machine and not the other. So create a cron job/scheduled task that will execute your php code and you should be fine.


Jason

IronCode
07-17-2003, 12:42 AM
lol do not start a cronjob on that.

The scripting looks ok to me, but you might want to try and remove the gaps between the info in the mail statement. I have heard (although not experienced) of people having issues with the data being split like you have it.

So instead of this,

mail(
"jeremyb@mobiletel.com",
"Question or Comment from website",
"Name: $name

Address: $address
City: $city
State: $state
Zip: $zip

Phone: $phone
Fax: $fax

Email: $email

Please contact me by: $contact

Question or Comment: $question
",
"From: ".$customer." <".$email.">\nX-Mailer: PHP/" . phpversion());


You'd have this,

mail("jeremyb@mobiletel.com","Question or Comment from website","Name: $name\n
Address: $address\nCity: $city\nState: $state\nZip: $zip\n\nPhone: $phone\n
Fax: $fax\nEmail: $email\n\nPlease contact me by: $contact\n
Question or Comment: $question\n","From: ".$customer." <".$email.">\nX-Mailer: PHP/" . phpversion());


Now i broke that down so that the page here wouldn't take off to far to the right. But it should all be one line in your script.

Also let me ask you this, Have you just commented out your mail statement and had it echo the results? From your post there isn't anything pointing to the fact that you know the info is making to the mail script.

Because there is only two things that i can think of that would prevent it from working, one that the variables are not getting passed to the mail script or your php settings are goofed. Have you ever had a mail script work on this server before? Have you ever had a php script period running on this server before?

Because once we know if the info is making to the mail script we would know that there is most likely something else at play.

Let me know how things work out.

jeremyb
07-17-2003, 03:51 PM
Iron Code,

Thanks for the information. I had tried what you said and still nothing. I guess maybe I need to find another hosting company. I cannot seem to get any help from those guys. Who are you hosting with? Would you mind if I email you the files and upload them to your host and see if they work fine on that server?

It is echo the information just fine. I am just having a problem with receiving the mail.

Thanks,
Jeremyb

ReadMe.txt
07-17-2003, 08:21 PM
the problem is probably whatever the PHP build is trying to use the send the mail then. I'm no expert on mail sending but if you look at www.php.net/mail and read the user notes.

I'm not sure whether just sending the mail command to an STMP server will work, but if it will then ini_set www.php.net/ini_set might be useful.

?gkj
07-18-2003, 07:06 PM
Look at this script:

http://www.arecaweb.com/php/mmex/mmex.html


It is a form results mailer that will send as many fields as you want & requires no php edit.

Check it out.