Solved

PHP email form not processing

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
The viewer will learn how to dynamically set the form action using jQuery.

706 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

18 Experts available now in Live!

Get 1:1 Help Now