Weborum Webmaster Forum > php email contact form script -for apache server
Help - Search - Members - Calendar
Full Version: php email contact form script -for apache server
Weborum Webmaster Forum > Web Page Design > PHP
sambkk
Hi guys
I am hoping you could give mesome help and tell me what I have to change in my email contact form.

I get this msg when I try my contact form.

The server encountered an unexpected condition which prevented it from fulfilling the request.
The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.


the server seems to be apache.

my code for the form is this:

<form name="form1" method="post" action="mail_t.php">

<input type="text" name="user" size="25">
<input type="text" name="emailaddress" size="25">
<textarea cols="10" rows="4" name="comments"></textarea>
<input type="submit" value="Send">
</form>

and my mail_t.php looks like this:
(the email adress removed as its not mine)

<?
$to = "xxx@xxxx.com";
$subject = "Email from website contact form";
$boundary = uniqid("");
$headers = "From: $from";
$body = "
Name :$user
Email :$emailaddress
Comment :$comments
";

if (mail($to, $subject, $body,$headers)) {
print( "Thank you for emailing us.Your file has been sent succesfully");
?>
<meta http-equiv=refresh content="1;URL=http://www.peacefulsangha.com/files/CUTH.html">
<?
}
else {
print( "Error: Unknown error ocurred. The message could not be sent. Please try again later.\n");
}

?>

the link to the page is here:

http://www.peacefulseasangha.com/sampleforliz/files/CU.html

I am lost as I dont really know php, this script has worked before on other servers.

thanks

sami
Joe
From what I can see, the only problem is that you are not sending any data.

Use $_GET to retreive the information from the form and store it in a variable to send.

[php]
$user = $_GET['user'];
$emailaddress = $_GET['emailaddress'];
$comments = $_GET['comments'];
[/php]

like so.
sambkk
hi joe thanks for the help.
unfortunately it didnt work.

here is what my mail_t.php file looks like now:


<?
$to = "xxx@xxxx.com";
$subject = "XXXEmail from website contact form";
$boundary = uniqid("");
$headers = "From: $from";
$body = "
Name :$_GET['user'];
Email :$_GET['emailaddress'];
Comment :$_GET['comments'];
";

if (mail($to, $subject, $body,$headers)) {
print( "Thank you for emailing us.Your file has been sent succesfully");
?>
<meta http-equiv=refresh content="1;URL=http://www.peacefulseasangha.com/sampleforliz/files/CUTH.html">
<?
}
else {
print( "Error: Unknown error ocurred. The message could not be sent. Please try again later.\n");
}

?>

perhaps I didnt follow your instructions carefully enough?

sami
Joe
Not quite right, I recommend you take a look at a script I wrote out a while back, it may be of some help to you.

http://forum.weborum.com/index.php?showtopic=3853
sambkk
thanks joe,
I'll have a look.

Sami
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.