Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail ( )

Status
Not open for further replies.

Soti

Programmer
Jul 9, 2001
34
0
0
US
Can someone please take a look at this code and tell me why the mail() is not working.
THX!

#!#TITLE
Take Action
#!#JS
#!#BODY
?>
<font size=2 face=Arial>
<h5>How much do you know about the status of women and girls? Test your
knowledge and take our facts about Women and Girls Quiz! Just take a
few minutes to complete the following 10 questions.</h5>

<form name=&quot;f&quot; action=&quot;<?php echo $PHP_SELF.&quot;?id=4.5&quot;; ?>&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;s&quot; value=&quot;1&quot;>

<b>Please enter your email address:</b>
<input type=text name=&quot;qa0&quot;><p>

<b>1. In 1997, ____ of households were headed by women?</b><p>
<input type=&quot;radio&quot; name=&quot;qa1&quot; value=&quot;A 18%&quot;>18%<br>
<input type=&quot;radio&quot; name=&quot;qa1&quot; value=&quot;B 25%&quot;>25%<br>
<input type=&quot;radio&quot; name=&quot;qa1&quot; value=&quot;C 30%&quot;>30%<br>
<input type=&quot;radio&quot; name=&quot;qa1&quot; value=&quot;D 46%&quot;>46%<br>
<input type=&quot;radio&quot; name=&quot;qa1&quot; value=&quot;E 51%&quot;>51%<br><p>

<b>2. In 1999, women hold ____ of the seats in the 535 member 106th Congress.</b><p>
<input type=&quot;radio&quot; name=&quot;qa2&quot; value=&quot;A 9%&quot;>9%<br>
<input type=&quot;radio&quot; name=&quot;qa2&quot; value=&quot;B 13%&quot;>13%<br>
<input type=&quot;radio&quot; name=&quot;qa2&quot; value=&quot;C 26%&quot;>26%<br>
<input type=&quot;radio&quot; name=&quot;qa2&quot; value=&quot;D 51%&quot;>51%<br>
<input type=&quot;radio&quot; name=&quot;qa2&quot; value=&quot;E 65%&quot;>65%<p>

<b>3. In 1992 and 1994, ____ of women registered to vote actually voted in the national elections. </b><p>
<input type=&quot;radio&quot; name=&quot;qa3&quot; value=&quot;A 29%&quot;>29%<br>
<input type=&quot;radio&quot; name=&quot;qa3&quot; value=&quot;B 41%&quot;>41%<br>
<input type=&quot;radio&quot; name=&quot;qa3&quot; value=&quot;C 62%&quot;>62%<br>
<input type=&quot;radio&quot; name=&quot;qa3&quot; value=&quot;D 80%&quot;>80%<br>
<input type=&quot;radio&quot; name=&quot;qa3&quot; value=&quot;E 95%&quot;>95%<p>

<b>4. In 1997, ____ of all women between the ages of 25 and 54 were in the labor force.</b><p>
<input type=&quot;radio&quot; name=&quot;qa4&quot; value=&quot;A 33%&quot;>33%<br>
<input type=&quot;radio&quot; name=&quot;qa4&quot; value=&quot;B 45%&quot;>45%<br>
<input type=&quot;radio&quot; name=&quot;qa4&quot; value=&quot;C 50%&quot;>50%<br>
<input type=&quot;radio&quot; name=&quot;qa4&quot; value=&quot;D 62%&quot;>62%<br>
<input type=&quot;radio&quot; name=&quot;qa4&quot; value=&quot;E 74%&quot;>74%<br><p>

<b>5. In 1997, women represented approximately ____ of lawyers and doctors and approximately ____ of engineers and fortune 500 corporate officers. </b><p>
<input type=&quot;radio&quot; name=&quot;qa5&quot; value=&quot;A 30%, 10%&quot;>30%,10%<br>
<input type=&quot;radio&quot; name=&quot;qa5&quot; value=&quot;B 45%, 15%&quot;>45%,15%<br>
<input type=&quot;radio&quot; name=&quot;qa5&quot; value=&quot;C 50%, 25%&quot;>50%,25%<br>
<input type=&quot;radio&quot; name=&quot;qa5&quot; value=&quot;D 62%, 38%&quot;>62%,38%<br>
<input type=&quot;radio&quot; name=&quot;qa5&quot; value=&quot;E 74%, 51%&quot;>74%,51%<br>
<p>

<b>6.In 1997, among year-round fulltime workers, women’s weekly earnings were ____ of men’s </b><p>
<input type=&quot;radio&quot; name=&quot;qa6&quot; value=&quot;A 55%&quot;>55%<br>
<input type=&quot;radio&quot; name=&quot;qa6&quot; value=&quot;B 65%&quot;>65%<br>
<input type=&quot;radio&quot; name=&quot;qa6&quot; value=&quot;C 75%&quot;>75%<br>
<input type=&quot;radio&quot; name=&quot;qa6&quot; value=&quot;D 85%&quot;>85%<br>
<input type=&quot;radio&quot; name=&quot;qa6&quot; value=&quot;E 95%&quot;>95%<p>

<b>7. In 1997, women and children (under 18) represented ____ of the total number of people living in poverty </b><p>
<input type=&quot;radio&quot; name=&quot;qa7&quot; value=&quot;A 33%&quot;>33%<br>
<input type=&quot;radio&quot; name=&quot;qa7&quot; value=&quot;B 51%&quot;>51%<br>
<input type=&quot;radio&quot; name=&quot;qa7&quot; value=&quot;C 63%&quot;>63%<br>
<input type=&quot;radio&quot; name=&quot;qa7&quot; value=&quot;D 75%&quot;>75%<br>
<input type=&quot;radio&quot; name=&quot;qa7&quot; value=&quot;E 80%&quot;>80%<p>

<b>8. In 1995, about one in every ____ American girls between the ages of 15 and 19 became pregnant. </b><p>
<input type=&quot;radio&quot; name=&quot;qa8&quot; value=&quot;A 5&quot;>5<br>
<input type=&quot;radio&quot; name=&quot;qa8&quot; value=&quot;B 10&quot;>10<br>
<input type=&quot;radio&quot; name=&quot;qa8&quot; value=&quot;C 15&quot;>15<br>
<input type=&quot;radio&quot; name=&quot;qa8&quot; value=&quot;D 35&quot;>35<br>
<input type=&quot;radio&quot; name=&quot;qa8&quot; value=&quot;E 60&quot;>60<p>

<b>9. Approximately ____ of high school girls participate in at least one school-sponsored sport. </b><p>
<input type=&quot;radio&quot; name=&quot;qa9&quot; value=&quot;A 15%&quot;>15%<br>
<input type=&quot;radio&quot; name=&quot;qa9&quot; value=&quot;B 27%&quot;>27%<br>
<input type=&quot;radio&quot; name=&quot;qa9&quot; value=&quot;C 42%&quot;>42%<br>
<input type=&quot;radio&quot; name=&quot;qa9&quot; value=&quot;D 68%&quot;>68%<br>
<input type=&quot;radio&quot; name=&quot;qa9&quot; value=&quot;E 82%&quot;>82%<p>

<b>10. In 1960, 38 percent of girls who graduated from high school enrolled in college the following fall. In 1996 ____ of girls who graduated from high school enrolled in college the following fall </b><p>
<input type=&quot;radio&quot; name=&quot;qa10&quot; value=&quot;A 32%&quot;>32%<br>
<input type=&quot;radio&quot; name=&quot;qa10&quot; value=&quot;B 49%&quot;>49%<br>
<input type=&quot;radio&quot; name=&quot;qa10&quot; value=&quot;C 56%&quot;>56%<br>
<input type=&quot;radio&quot; name=&quot;qa10&quot; value=&quot;D 70%&quot;>70%<br>
<input type=&quot;radio&quot; name=&quot;qa10&quot; value=&quot;E 84%&quot;>84%<p>
<CENTER>
<input type=&quot;image&quot; src=&quot;images/submit.gif&quot; width=70 height=51 border=0>
</CENTER>
</fORM>
</font>

<?php
if(!isset($qa)){
$qa = &quot;&quot;;

} else {

if(strlen($qa2)==0 || strlen($qa3)==0 || strlen($qa4)==0) {
?>

<font face=Verdana, Arial, Helvetica, sans-serif size=-1>The quiz was not submitted because not all of the questions were answered. Please click the &quot;Back&quot; button on your web browser and correct the submission. Thank you!<br>
<br>

<?php } else {


$subject = &quot;Quiz&quot;;
$m = sprintf (&quot;Quiz\n----------------------\n\n %s\nPlease enter your email address:%s\nIn 1997, ____ of households were headed by women %s\nIn 1999, women hold ____ of the seats in the 535 member 106th Congress %s\nIn 1992 and 1994, ____ of women registered to vote actually voted in the national elections. %s\nIn 1997, ____ of all women between the ages of 25 and 54 were in the labor force %s\nIn 1997, women represented approximately ____ of lawyers and doctors and approximately ____ of engineers and fortune 500 corporate officers %s\nIn 1997, among year-round fulltime workers, women’s weekly earnings were ____ of men’s %s\nIn 1997, women and children (under 18) represented ____ of the total number of people living in poverty %s\nIn 1995, about one in every ____ American girls between the ages of 15 and 19 became pregnant %s\nApproximately ____ of high school girls participate in at least one school-sponsored sport %s\nIn 1960, 38 percent of girls who graduated from high school enrolled in college the following fall. In 1996 ____ of girls who graduated from high school enrolled in college the following fall&quot;, stripslashes($qa0), stripslashes($qa1), stripslashes($qa2), stripslashes($qa3), stripslashes($qa4), stripslashes($qa5), stripslashes($qa6), stripslashes($qa7), stripslashes($qa8), stripslashes($qa9), stripslashes($qa10));

mail(&quot;mlluberes@hotmail.com&quot;, $subject, $m, &quot;From:$qa0&quot;);
}

?>
<font face=Verdana, Arial, Helvetica, sans-serif size=-1>Your submission has been successfully sent. Thank you!

<?php } ?>

 
This is what i use mate:

$recipient = &quot;name <e-mail address>&quot;;
$subject = &quot;subject&quot;;
$message = &quot;message for e-mail&quot;;
$extra = &quot;From: name <e-mail address>&quot;;

mail ($recipient, $subject, $message, $extra);

hope that it helps

 
Soti,

you are telling PHP that $qa has to be set in order for the email to get sent. Nowhere in your script are you setting qa!

I made some minor modifications to your script and you can test it at
First, don't fill out all of the fields, and you will see the way the error is displayed. Then, answer all of the questions and you will receive the success message.

Lastly, you can click on the view source link at the top to see what I did.

It works like a charm for me.


Chad. ICQ: 54380631
 
Hi-
Perhaps our server settings are different. When I follow the link above it works great--if I upload it to my server it generates several errors. Even after making minor changes I can't get it to work correctly! Can you let me know if you have received any of my test messages?

In any event, I will continue working on this until 1:00--then I'm off to a much needed vacation =)

Thanks for all that you have done!
 
Well i cant help, but have a nice holiday ;-)
(btw are u uploading ascii and not binary? (maybe a silly question but sometimes it helps))

And maybe sendmail is not installed with ure PHP, then it will never have mailfunction nor will it send mail. mcvdmvs
-- &quot;It never hurts to help&quot; -- Eek the Cat
 
Thanks! I have several other forms on the site that work perfectly! This ones really got me!!
Soti
 
GOT IT!!
Here's the code:
#!#TITLE
Take Action
#!#JS
#!#BODY
?>

<?php if(empty($s)) { ?>

<font size=2 face=Arial>
<h5>How much do you know about the status of women and girls? Test your
knowledge and take our facts about Women and Girls Quiz! Just take a
few minutes to complete the following 10 questions.</h5>

<form name=&quot;f&quot; action=&quot;page.php?id=4.9.txt&quot; method=&quot;POST&quot;>
<input type=&quot;hidden&quot; name=&quot;id&quot; value=&quot;4.9&quot;>
<input type=&quot;hidden&quot; name=&quot;s&quot; value=&quot;1&quot;>


<b>1. In 1997, ____ of households were headed by women?</b><p>
<input type=&quot;radio&quot; name=&quot;f1&quot; value=&quot;A 18%&quot;>18%<br>
<input type=&quot;radio&quot; name=&quot;f1&quot; value=&quot;B 25%&quot;>25%<br>
<input type=&quot;radio&quot; name=&quot;f1&quot; value=&quot;C 30%&quot;>30%<br>
<input type=&quot;radio&quot; name=&quot;f1&quot; value=&quot;D 46%&quot;>46%<br>
<input type=&quot;radio&quot; name=&quot;f1&quot; value=&quot;E 51%&quot;>51%<br><p>

<b>2. In 1999, women hold ____ of the seats in the 535 member 106th Congress.</b><p>
<input type=&quot;radio&quot; name=&quot;f2&quot; value=&quot;A 9%&quot;>9%<br>
<input type=&quot;radio&quot; name=&quot;f2&quot; value=&quot;B 13%&quot;>13%<br>
<input type=&quot;radio&quot; name=&quot;f2&quot; value=&quot;C 26%&quot;>26%<br>
<input type=&quot;radio&quot; name=&quot;f2&quot; value=&quot;D 51%&quot;>51%<br>
<input type=&quot;radio&quot; name=&quot;f2&quot; value=&quot;E 65%&quot;>65%<p>

<b>3. In 1992 and 1994, ____ of women registered to vote actually voted in the national elections. </b><p>
<input type=&quot;radio&quot; name=&quot;f3&quot; value=&quot;A 29%&quot;>29%<br>
<input type=&quot;radio&quot; name=&quot;f3&quot; value=&quot;B 41%&quot;>41%<br>
<input type=&quot;radio&quot; name=&quot;f3&quot; value=&quot;C 62%&quot;>62%<br>
<input type=&quot;radio&quot; name=&quot;f3&quot; value=&quot;D 80%&quot;>80%<br>
<input type=&quot;radio&quot; name=&quot;f3&quot; value=&quot;E 95%&quot;>95%<p>

<b>4. In 1997, ____ of all women between the ages of 25 and 54 were in the labor force.</b><p>
<input type=&quot;radio&quot; name=&quot;f4&quot; value=&quot;A 33%&quot;>33%<br>
<input type=&quot;radio&quot; name=&quot;f4&quot; value=&quot;B 45%&quot;>45%<br>
<input type=&quot;radio&quot; name=&quot;f4&quot; value=&quot;C 50%&quot;>50%<br>
<input type=&quot;radio&quot; name=&quot;f4&quot; value=&quot;D 62%&quot;>62%<br>
<input type=&quot;radio&quot; name=&quot;f4&quot; value=&quot;E 74%&quot;>74%<br><p>

<b>5. In 1997, women represented approximately ____ of lawyers and doctors and approximately ____ of engineers and fortune 500 corporate officers. </b><p>
<input type=&quot;radio&quot; name=&quot;f5&quot; value=&quot;A 30%, 10%&quot;>30%,10%<br>
<input type=&quot;radio&quot; name=&quot;f5&quot; value=&quot;B 45%, 15%&quot;>45%,15%<br>
<input type=&quot;radio&quot; name=&quot;f5&quot; value=&quot;C 50%, 25%&quot;>50%,25%<br>
<input type=&quot;radio&quot; name=&quot;f5&quot; value=&quot;D 62%, 38%&quot;>62%,38%<br>
<input type=&quot;radio&quot; name=&quot;f5&quot; value=&quot;E 74%, 51%&quot;>74%,51%<br>
<p>

<b>6.In 1997, among year-round fulltime workers, women’s weekly earnings were ____ of men’s </b><p>
<input type=&quot;radio&quot; name=&quot;f6&quot; value=&quot;A 55%&quot;>55%<br>
<input type=&quot;radio&quot; name=&quot;f6&quot; value=&quot;B 65%&quot;>65%<br>
<input type=&quot;radio&quot; name=&quot;f6&quot; value=&quot;C 75%&quot;>75%<br>
<input type=&quot;radio&quot; name=&quot;f6&quot; value=&quot;D 85%&quot;>85%<br>
<input type=&quot;radio&quot; name=&quot;f6&quot; value=&quot;E 95%&quot;>95%<p>

<b>7. In 1997, women and children (under 18) represented ____ of the total number of people living in poverty </b><p>
<input type=&quot;radio&quot; name=&quot;f7&quot; value=&quot;A 33%&quot;>33%<br>
<input type=&quot;radio&quot; name=&quot;f7&quot; value=&quot;B 51%&quot;>51%<br>
<input type=&quot;radio&quot; name=&quot;f7&quot; value=&quot;C 63%&quot;>63%<br>
<input type=&quot;radio&quot; name=&quot;f7&quot; value=&quot;D 75%&quot;>75%<br>
<input type=&quot;radio&quot; name=&quot;f7&quot; value=&quot;E 80%&quot;>80%<p>

<b>8. In 1995, about one in every ____ American girls between the ages of 15 and 19 became pregnant. </b><p>
<input type=&quot;radio&quot; name=&quot;f8&quot; value=&quot;A 5&quot;>5<br>
<input type=&quot;radio&quot; name=&quot;f8&quot; value=&quot;B 10&quot;>10<br>
<input type=&quot;radio&quot; name=&quot;f8&quot; value=&quot;C 15&quot;>15<br>
<input type=&quot;radio&quot; name=&quot;f8&quot; value=&quot;D 35&quot;>35<br>
<input type=&quot;radio&quot; name=&quot;f8&quot; value=&quot;E 60&quot;>60<p>

<b>9. Approximately ____ of high school girls participate in at least one school-sponsored sport. </b><p>
<input type=&quot;radio&quot; name=&quot;f9&quot; value=&quot;A 15%&quot;>15%<br>
<input type=&quot;radio&quot; name=&quot;f9&quot; value=&quot;B 27%&quot;>27%<br>
<input type=&quot;radio&quot; name=&quot;f9&quot; value=&quot;C 42%&quot;>42%<br>
<input type=&quot;radio&quot; name=&quot;f9&quot; value=&quot;D 68%&quot;>68%<br>
<input type=&quot;radio&quot; name=&quot;f9&quot; value=&quot;E 82%&quot;>82%<p>

<b>10. In 1960, 38 percent of girls who graduated from high school enrolled in college the following fall. In 1996 ____ of girls who graduated from high school enrolled in college the following fall </b><p>
<input type=&quot;radio&quot; name=&quot;f10&quot; value=&quot;A 32%&quot;>32%<br>
<input type=&quot;radio&quot; name=&quot;f10&quot; value=&quot;B 49%&quot;>49%<br>
<input type=&quot;radio&quot; name=&quot;f10&quot; value=&quot;C 56%&quot;>56%<br>
<input type=&quot;radio&quot; name=&quot;f10&quot; value=&quot;D 70%&quot;>70%<br>
<input type=&quot;radio&quot; name=&quot;f10&quot; value=&quot;E 84%&quot;>84%<p>
<CENTER>
<input type=&quot;image&quot; src=&quot;images/submit.gif&quot; width=70 height=51 border=0>
</CENTER>
</fORM>
</font>

<?php
} else {

if(strlen($f2)==0)
{
?>

The form was not submitted because not all of the required fields have been filled out. Please click the &quot;Back&quot; button on your web browser and correct the submission. Thank you!<br>
<br>

<?php } else {
//mail setup
$subject=&quot;QUIZ&quot;;
$m = sprintf(&quot;Quiz\n----------------------\n\n %s\nIn 1997, ____ of households were headed by women %s\nIn 1999, women hold ____ of the seats in the 535 member 106th Congress %s\nIn 1992 and 1994, ____ of women registered to vote actually voted in the national elections. %s\nIn 1997, ____ of all women between the ages of 25 and 54 were in the labor force %s\nIn 1997, women represented approximately ____ of lawyers and doctors and approximately ____ of engineers and fortune 500 corporate officers %s\nIn 1997, among year-round fulltime workers, women’s weekly earnings were ____ of men’s %s\nIn 1997, women and children (under 18) represented ____ of the total number of people living in poverty %s\nIn 1995, about one in every ____ American girls between the ages of 15 and 19 became pregnant %s\nApproximately ____ of high school girls participate in at least one school-sponsored sport %s\nIn 1960, 38 percent of girls who graduated from high school enrolled in college the following fall. In 1996 ____ of girls who graduated from high school enrolled in college the following fall&quot;, stripslashes($f1), stripslashes($f2), stripslashes($f3), stripslashes($f4), stripslashes($f5), stripslashes($f6), stripslashes($f7), stripslashes($f8), stripslashes($f9), stripslashes($f10));

//send mail message
mail(&quot;mlluberes@hotmail&quot;, $subject, &quot; $m $f1 \n $f2 \n $f3 \n $f4 \n $f5 \n $f6 \n $f7 \n $f8 \n $f9 \n $f10&quot;);
?>

Your submission has been successfully sent. Thank you!



<?php
}
}
 
Thanks for all of your help! Really appreciate it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top