Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PHP email form not processing

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

809 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