Link to home
Start Free TrialLog in
Avatar of guy4graphics
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\nRequested 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!?
Avatar of guy4graphics
guy4graphics

ASKER

NOTE:
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";

are not doing anything
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\nRequested 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.
hum, still shows emailerror.php
ASKER CERTIFIED SOLUTION
Avatar of rdivilbiss
rdivilbiss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zyloch
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.