Solved

PHP email form not processing

Posted on 2007-03-31
5
255 Views
Last Modified: 2008-02-01
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!?
0
Comment
Question by:guy4graphics
  • 2
  • 2
5 Comments
 
LVL 1

Author Comment

by:guy4graphics
ID: 18831081
NOTE:
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";

are not doing anything
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18831130
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.
0
 
LVL 1

Author Comment

by:guy4graphics
ID: 18831143
hum, still shows emailerror.php
0
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 500 total points
ID: 18831154
write your variables to see what you are getting.

e.g. $from = $_POST['email'] ;
echo $from;

Make sure your parameters are coming in correctly,
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 18831194
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now