Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
dreadsiren is on a distinguished road
 
Posts: 2
Join Date: Jan 2012
Default php form trouble, whitescreen - 01-08-2012, 08:33 PM

I've been trying to make my contact form php work but am getting nowhere... the htm end works but dead ends to white page on form.php.. I know I have just been coding too many hours and am prob not seeing my error... form.php contents below, thanks in advance htm is @ www.bd2thbn.com/contact.htm

<?php
$errors = '';
$myemail = 'mike@bd2thbn.com';
if(empty($_POST['name'])
empty($_POST['email'])
empty($_POST['message'])
{
$errors .= "\n Error: all fields are required";
}

$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n Email: $email \n Phone: $phone \n Message: \n $message";

$headers = "From: $myemail\n";
$headers .= "Reply-To: $email";

mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: thankyou.html');
}
?>

Last edited by dreadsiren; 01-08-2012 at 08:41 PM. Reason: posted wrong php
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Junior Member
dreadsiren is on a distinguished road
 
Posts: 2
Join Date: Jan 2012
Default 01-08-2012, 09:07 PM

now its finally giving me an error!

Parse error: syntax error, unexpected T_EMPTY in /home/a5378388/public_html/mail.php on line 5

cant figure out what is wrong with line 5?!? anyone?? please
Reply With Quote
(#3 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 544
Join Date: Dec 2010
Default 01-08-2012, 09:21 PM

Please try the following code:

if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com