form mail help please


#1

Well it’s just not my day… I need to have this form up by tonight and my mind is in a million different places and I just can’t concentrate.

I have the form up, but for the life of me I can’t get the php document that sends the info to me to work…

If anyone can help I’d be greatly appreciative…

http://www.glidersanonymous.com/gettogether.html


#2

You`ll need to post your code so we can take a look.

:)

#3

Here’s what I have so far… it’s giving me and error on line 24.

[code]<?
$sendto="tmarie@glidersanonymous.com";
$emailsubject=“Get Together Attendance”;
$thankyou=“Your reservation has been submitted. See you in August!”;

if ($submit) {

if ($name <= “”)
$message=“Please enter your name.”;
else if ($screenname <= “”)
$message=“Please enter your GA Screenname.”;
else if ($address <= “”)
$message=“Please enter your address.”;
else if ($citystate <= “”)
$message=“Please enter your city and state.”;
else if ($phone <= “”)
$message=“Please enter your contact phone number.”;
else if ($email <= “”)
$message=“Please enter a valid email address.”;
else if ($numberofgliders <= “”)
$message=“Please enter a number of gliders.”;
else if ($numberofadults <= “”);
$message=“Please enter the number of adults attending.”;
else if ($numberofchild <= “”);
$message=“Please enter the number of children attending.”;

if ($message)
echo ($message);
else {
mail("$sendto",
“$emailsubject”,
“rnName: $namernEmail: $emailrnScreenname: $screennamernAddress: $addressrnCity/State: $citystaternPhone Number: $phonernDays Attending: $friday $saturday $sunday $otherrnOther Comments: rn$otherdaysattendingrnNumber of Gliders: $numberofglidersrnNumber of Adults: $numberofadultsrnNumber of Children: $numberofchildrnStaying in Hotel: $hotelrnAmusement Park: $amusementparkrnGift Exchange: $giftexchangernPlanning Committee: $planningcommittee”,
“From: $name <$email>”);
echo ("

     $thankyou");
die();
}
}
?>[/code]

I also was wanting to verify that radio and checkboxes had information too… right now I only have it verifying text boxes…

Thanks so much.


#4

Ok, firstly, you should always use the $_POST superglobal when passing form data.

Secondly, your error messages need to be concatenated, so that if any of them are displayed, you see all of them. As it is at the moment, each time $message is called it will overwrite the previous $message variable. Also you don`t need if else statements as message will only ever hold one value. In this instance, just if statements will work best.

And finally, you appear to be missing a brace in your code.

Give this a try:


<?php 

$sendto="tmarie@glidersanonymous.com"; 
$emailsubject="Get Together Attendance"; 
$thankyou="Your reservation has been submitted.  See you in August!"; 

if ($_POST['submit']) {

   if ($_POST['name'] == "")
       $message .= "Please enter your name.<br>";
   if ($_POST['screenname'] == "")
       $message .= "Please enter your GA Screenname.<br>";
   if ($_POST['address'] == "")
       $message .= "Please enter your address.<br>";
   if ($_POST['citystate'] == "")
       $message .= "Please enter your city and state.<br>";
   if ($_POST['phone'] == "")
       $message .= "Please enter your contact phone number.<br>";
   if ($_POST['email'] == "")
       $message .= "Please enter a valid email address.<br>";
   if ($_POST['numberofgliders'] == "")
       $message .= "Please enter a number of gliders.<br>";
   if ($_POST['numberofadults'] == "");
       $message .= "Please enter the number of adults attending.<br>";
   if ($_POST['numberofchild'] == "");
       $message .= "Please enter the number of children attending.<br>";
       
if ($message)

{

echo ($message);
exit; 

} else {

mail("$sendto",
"$emailsubject",
"rnName: $_POST['name']rnEmail: $_POST['email']rnScreenname: $_POST['screenname']rnAddress: $_POST['address']rnCity/State: $_POST['citystate']rnPhone Number: $_POST['phone']rnDays Attending: $_POST['friday'] $_POST['saturday'] $_POST['sunday'] $_POST['other']rnOther Comments: rn$_POST['otherdaysattending']rnNumber of Gliders: $_POST['numberofgliders']rnNumber of Adults: $_POST['numberofadults']rnNumber of Children: $_POST['numberofchild']rnStaying in Hotel: $_POST['hotel']rnAmusement Park: $_POST['amusementpark']rnGift Exchange: $_POST['giftexchange']rnPlanning Committee: $_POST['planningcommittee']",
"From: $_POST['name'] <$_POST['email']>");
echo ("<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$thankyou");
exit;

}
}

?>

See if that works. :)


#5

Yeah I added the bracket myself after I posted this. I also added html to the beginning for a customized thank you page. Now I am getting errors in the end of the php code saying:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www/t/tmarie820/htdocs/submitattendance.php on line 139

I had one on 140 before this one… deleted a space and tried again and got the one with 139.

It seems to always be around this part:

[code]

if ($message)

{

echo ($message);
exit;[/code]

I’ve never used $_POST before… how does it help exactly. I have two other forms on my site that don’t use it that work fine.


#6

If you have register globals OFF on your server, then you need to use the $_POST array. Sounds like you have them ON, as you say its working ok. However, its always good practice to use the $_POST array because you never know if you might want to switch to another server later on. Using $_POST ensures that your form data will work regardless of whether RG are on or off.

With regards to your error, try removing the brackets when you echo $message;


if ($message) 

{ 

echo $message; 
exit;

#7

Dang it… this is making me mad lol… it’s still not working… how can I write them any other time… sigh

should i just take the echo out? i don’t have it in the other two… but i thought i’d try it.


#8

Sorry, its nothing to do with the echo statement. Its actually the mail function that is the problem. I haven`t coded it correctly. Apologies. Dunno what I was thinking really. LOL.

As you say that your code works ok not using $_POST, try this. It wont matter if $_POST is used in the first part.


<?php 

$sendto="tmarie@glidersanonymous.com"; 
$emailsubject="Get Together Attendance"; 
$thankyou="Your reservation has been submitted.  See you in August!"; 

if ($_POST['submit']) { 

   if ($_POST['name'] == "") 
       $message .= "Please enter your name.<br>"; 
   if ($_POST['screenname'] == "") 
       $message .= "Please enter your GA Screenname.<br>"; 
   if ($_POST['address'] == "") 
       $message .= "Please enter your address.<br>"; 
   if ($_POST['citystate'] == "") 
       $message .= "Please enter your city and state.<br>"; 
   if ($_POST['phone'] == "") 
       $message .= "Please enter your contact phone number.<br>"; 
   if ($_POST['email'] == "") 
       $message .= "Please enter a valid email address.<br>"; 
   if ($_POST['numberofgliders'] == "") 
       $message .= "Please enter a number of gliders.<br>"; 
   if ($_POST['numberofadults'] == ""); 
       $message .= "Please enter the number of adults attending.<br>"; 
   if ($_POST['numberofchild'] == ""); 
       $message .= "Please enter the number of children attending.<br>"; 
        
if ($message) 

{ 

echo ($message); 
exit; 

} else { 

mail("$sendto",
"$emailsubject", 
"rnName: $namernEmail: $emailrnScreenname: $screennamernAddress: $addressrnCity/State: $citystaternPhone Number: $phonernDays Attending: $friday $saturday $sunday $otherrnOther Comments: rn$otherdaysattendingrnNumber of Gliders: $numberofglidersrnNumber of Adults: $numberofadultsrnNumber of Children: $numberofchildrnStaying in Hotel: $hotelrnAmusement Park: $amusementparkrnGift Exchange: $giftexchangernPlanning Committee: $planningcommittee",
"From: $name <$email>");
echo ("<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$thankyou"); 
exit;

} 
} 

?>
:)

#9

thanks i will try that here in a bit… I just got done with a 12 hour shift…


#10

if i want to take out the thank you (i am going to add html at the top to customize my own thank you page) will this work:

[code]<?php

$sendto="tmarie@glidersanonymous.com";
$emailsubject=“Get Together Attendance”;

if ($_POST[‘submit’]) {

if ($_POST[‘name’] == “”)
$message .= “Please enter your name.
”;
if ($_POST[‘screenname’] == “”)
$message .= “Please enter your GA Screenname.
”;
if ($_POST[‘address’] == “”)
$message .= “Please enter your address.
”;
if ($_POST[‘citystate’] == “”)
$message .= “Please enter your city and state.
”;
if ($_POST[‘phone’] == “”)
$message .= “Please enter your contact phone number.
”;
if ($_POST[‘email’] == “”)
$message .= “Please enter a valid email address.
”;
if ($_POST[‘numberofgliders’] == “”)
$message .= “Please enter a number of gliders.
”;
if ($_POST[‘numberofadults’] == “”);
$message .= “Please enter the number of adults attending.
”;
if ($_POST[‘numberofchild’] == “”);
$message .= “Please enter the number of children attending.
”;

if ($message)

{

echo ($message);
exit;

} else {

mail("$sendto",
“$emailsubject”,
“rnName: $namernEmail: $emailrnScreenname: $screennamernAddress: $addressrnCity/State: $citystaternPhone Number: $phonernDays Attending: $friday $saturday $sunday $otherrnOther Comments: rn$otherdaysattendingrnNumber of Gliders: $numberofglidersrnNumber of Adults: $numberofadultsrnNumber of Children: $numberofchildrnStaying in Hotel: $hotelrnAmusement Park: $amusementparkrnGift Exchange: $giftexchangernPlanning Committee: $planningcommittee”,
“From: $name <$email>”);
exit;

}
}

?>
[/code]

I did that and it worked and my cusotm html worked but i got no email???


#11

Do you use other scripts that use the mail() function? You might need to alter your PHP.ini file and change your sendmail options.

If /usr/sbin/sendmail isn`t working, then try changing your sendmail path to /usr/sbin/sendmail -t -f username

Replace ‘username’ with your own username. Not that this only works on Unix servers.


#12

It’s not sendmail b/c I have two other forms on my site that use it with no problems. Thanks tho…


#13

Could be that the mail function isn`t getting called in your script, which would point to the first part of the if statement always returning true.