guy4graphics
asked on
PHP email form not processing
I put this php together to process an email form:
<?php
$to = "EMAILOMITTED";
$from = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$stickers = $_REQUEST['stickers'] ;
$message = "Name: " .$name."\n\nMailing Address:\n" .$_REQUEST['comments']."\n \nRequeste d Bumper Stickers:\n" .$stickers;
$headers = "From: $from";
$subject = "JBNEWS - Bumper Sticker Request";
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
if (!empty($to) && !empty($from) && !empty($message) && !empty($headers) && !empty($subject)) {
$send = mail($to, $from, $subject, $message, $headers);
if($send) {
header("Location: emailsent.php");
exit;
}
}
header("Location: emailerror.php");
exit;
?>
When I fill out all the forms and submit I get the emailerror.php instead of emailsent.php! Any suggestions!?
<?php
$to = "EMAILOMITTED";
$from = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$stickers = $_REQUEST['stickers'] ;
$message = "Name: " .$name."\n\nMailing Address:\n" .$_REQUEST['comments']."\n
$headers = "From: $from";
$subject = "JBNEWS - Bumper Sticker Request";
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
if (!empty($to) && !empty($from) && !empty($message) && !empty($headers) && !empty($subject)) {
$send = mail($to, $from, $subject, $message, $headers);
if($send) {
header("Location: emailsent.php");
exit;
}
}
header("Location: emailerror.php");
exit;
?>
When I fill out all the forms and submit I get the emailerror.php instead of emailsent.php! Any suggestions!?
Nor should they be...$fields{..} is meaningless.
<?php
$to = "EMAILOMITTED";
$from = $_POST['email'] ;
$name = $_POST['name'] ;
$stickers = $_POST['stickers'] ;
$message = "Name: " .$name."\n\nMailing Address:\n" .$_REQUEST['comments']."\n \nRequeste d Bumper Stickers:\n" .$stickers;
$headers = "From: $from";
$subject = "JBNEWS - Bumper Sticker Request";
if (!empty($to) && !empty($from) && !empty($message) && !empty($headers) && !empty($subject)) {
$send = mail($to, $from, $subject, $message, $headers);
if($send) {
header("Location: emailsent.php");
exit;
}
}
header("Location: emailerror.php");
exit;
Try that.
<?php
$to = "EMAILOMITTED";
$from = $_POST['email'] ;
$name = $_POST['name'] ;
$stickers = $_POST['stickers'] ;
$message = "Name: " .$name."\n\nMailing Address:\n" .$_REQUEST['comments']."\n
$headers = "From: $from";
$subject = "JBNEWS - Bumper Sticker Request";
if (!empty($to) && !empty($from) && !empty($message) && !empty($headers) && !empty($subject)) {
$send = mail($to, $from, $subject, $message, $headers);
if($send) {
header("Location: emailsent.php");
exit;
}
}
header("Location: emailerror.php");
exit;
Try that.
ASKER
hum, still shows emailerror.php
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Perhaps you should also try and include \r\n\r\n after your last header, for instance
$headers = "From: $from" . '\r\n\r\n';
I don't know if it will do anything, but worth a shot.
$headers = "From: $from" . '\r\n\r\n';
I don't know if it will do anything, but worth a shot.
ASKER
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
are not doing anything