Jump to content

Archived

This topic is now archived and is closed to further replies.

vivefree

For someone who know's their stuff...

Recommended Posts

I've created a simple form online which is then translated into a message stored in a php variable then sent using the mail() function.

My first page has the form.  The form's action is set to: vol_app.php.  The php code in vol_app.php looks like as follows:

<?php

$cname = $_POST["name"];
$caddress = $_POST["address"];
$ccity = $_POST["city"];
$cphone = $_POST["phone"];
$cinterests = $_POST["interests"];
$cmessage = $_POST["message"];
$coded_name = htmlspecialchars($cname);
$coded_address = htmlspecialchars($caddress);
$coded_city  = htmlspecialchars($ccity);
$coded_phone = htmlspecialchars($cphone);
$coded_interests = htmlspecialchars($cinterests);
$coded_message = htmlspecialchars($cmessage);

if($_POST["morning"] && $_POST["afternoon"]) $shift_for_message = "Both";
if($_POST["morning"] && !$_POST["afternoon"]) $shift_for_message = "Morning";
if(!$_POST["morning"] && $_POST["afternoon"]) $shift_for_message = "Afternoon";


$body = "Name: ".$coded_name."\n\nPhone: ".$coded_phone."\n\nAddress: \n".$coded_address."\n".$coded_city."\n\nHobbies or Interests:\n".$coded_interests."\n\nMorning or Evening Shift?: ".$shift_for_message."\n\nWhy you choose to volunteer at Desert Manna:\n".$coded_message;
$to = "myemail@mydomain.net";
$subject = "Volunteer Application";

mail($to, $subject, $body);
?>


Here's my problem.  Everytime I use this script I get two emails.  The first email contains all of the information in the $body variable, except the embedded variables are just blank.  The email looks like this:

Name:
Phone:
etc...

The second email is works as planned.
If anyone can help me with this I would greatly appreciate it!

Share this post


Link to post
Share on other sites
Can you post the script that writes out the form? It sounds like you're sending an email before the form is filled in. But without seeing more code, it is impossible to determine what's wrong.

Ken

Share this post


Link to post
Share on other sites
Here is the full code for each page in .rtf (text) form:

1.  Page with the form - http://desertmanna.org/junk/1.rtf
2.  The php page that sends the email - http://desertmanna.org/junk/2.rtf

Have at it!

Share this post


Link to post
Share on other sites
It would have been much better if you had posted the sources here in the forum.
Just paste each into a message and surround the code with the [b][nobbc][code][/code][/nobbc][/b] tags.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.