Solved

PHP email form not processing

Posted on 2007-03-31
5
256 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

777 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