Log in

View Full Version : PHP Form Mail Script



eday_2010
03-06-2007, 06:13 PM
I am trying to get a simple form mail script to work, with no luck so far. I came across a basic version of the below script and modified it for my use. However, it's giving me a 500 Internal Error. Here is my php script:


<?
if ($_POST["Submit"]){

if ($_POST["Name"] and $_POST["Address"] and $_POST["Apt_Suite"] and $_POST["City"] and $_POST["Province"] and $_POST["Postal_Code"] and $_POST["Phone"] and $_POST["Email"] and $_POST["Publication_Title"] and $_POST["#_Copies_English"] and $_POST["#_Copies_French"] and $_POST["Details"]){

mail (
"eday2010@gmail.com",
"Publication Order Request (EN)",
"
Name: ".$_POST['Name']."
Address: ".$_POST['Address']."
Apt/Suite: ".$_POST['Apt_Suite']."
City: ".$_POST['City']."
Province or Territory: ".$_POST['Province']."
Postal Code: ".$_POST['Postal_Code']."
Phone: ".$_POST['Phone']."
E-mail: ".$_POST['Email']."
Publication Title: ".$_POST['Publication_Title']."
# of English Copies: ".$_POST['#_Copies_English']."
# of French Copies: ".$_POST['#_Copies_French']."
Details/Comments: ".$_POST['Details']."
",
"From: ".$_POST['Name']." <".$_POST['Email'].">");

header("Location: http://www.wnstudios.ca/en/thankyou2.html");
exit();
}
?>

And the actual form is here: http://www.wnstudios.ca/en/order-commandez.html

Any ideas? I can't find anything in the error log.

TheBigT
03-06-2007, 11:53 PM
It looks like a problem with your server... I didn't notice anything wrong with your mail script. I think it might be that php is not "talking" with your mail server. Make sure you are allowed to use mail().

I have a home server where I can not use mail()

GhettoT
03-07-2007, 02:01 AM
To test to see if you are allowed to use the mail() function try using this simple php/html contact script.

(contact.html)


<form method="post" action="http://www.EXAMPLE.com/sendmail.php">
<div align="center" style="padding-left:10px">Name: <input name="name" type="text" /><br /></div>
<div align="center" style="padding-left:10px">Email: <input name="email" type="text" /><br /></div>
Message:<br />
<textarea name="message" rows="15" cols="40" style="border:#FFFF00 2px">
</textarea><br />
<input type="image" src="http://www.team330.org/images/go.png" />
</form>

sendmail.php


<?
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$name = $_REQUEST['name'] ;

mail( "EMAIL@exampl.com", "$email",
$message, "From: $name" );
header( "Location: http://www.team330.org/" );
?>

thetestingsite
03-07-2007, 02:10 AM
Working for me as far as the redirect to thankyou2.html, but not sure about the mail part.


I have a home server where I can not use mail()

I too run a home server (as well as some others), and I have a mail server (application) running on my [home] server. If you would like one, I suggest downloading/installing hMailServer (http://www.hmailserver.com/).


EDIT: Sorry GT, cross posted.

GhettoT
03-07-2007, 06:11 AM
No problem, its always cool to see other ways of fixing potential problems. Hopefully he can find a fix.

eday_2010
03-09-2007, 06:10 PM
How do I expand the code to send more than just one field from a form? I have several fields of info that need to be sent.

The pearl script I was using was working, but I was fiddlign this morning with the site and not I get the 500 Internal error again, so I don't know if it's something I did or my server. The server has had issues in the past.