Jump to content


Photo

For someone who know's their stuff...


  • Please log in to reply
3 replies to this topic

#1 vivefree

vivefree
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 August 2006 - 03:55 AM

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!

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 23 August 2006 - 04:10 AM

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

#3 vivefree

vivefree
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 August 2006 - 04:27 AM

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!

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 23 August 2006 - 04:34 AM

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 [code][/code] tags.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users