...

View Full Version : $_POST not getting data from HTML Form



stoli7188
08-10-2007, 04:28 PM
hey everyone I am new to these forums but after spending about 3 hours googling and playing around with the code I cant get my forms to work.

What i am trying to do is have my form email the results to an email address. Here is the contact page which the form is on:



<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="content" content="plumbing, heating, hvac, cooling, new work, service call, repair, renovation, mulco, quogue, long island, suffolk county plumber">
<meta name="author" content="mulco plumbing, mulco heating, mulco mechanical, quogue, long island, suffolk county, new york">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Mulco Plumbing, Heating, & HVAC for Suffolk County, Long Island - Contact</title>
<meta name="Microsoft Border" content="tlb">
</head>


<body>

<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="655" id="AutoNumber5">
<tr>
<td width="645"><font size="6">Contact<img border="1" src="BD18225_.gif" align="right" width="57" height="57"></font><p>
Mulco Mechanical<br>
44 Old Country Road<br>
Quogue, NY 11949</p>


<p>
<a href="http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=&daddr=44+Old+Country+Road,+Quogue,+NY&sll=16.467695,-72.421875&sspn=101.109306,144.667969&ie=UTF8&ll=40.837678,-72.607505&spn=0.011202,0.01766&z=16&om=1">
Get Directions</a> here from Google Maps</p>


<p>&nbsp;</p>


<p>To schedule service or for further inquiries please Call Now!</p>


<p><b>631.728.9098<br>
631.653.8181</b></p>


<p>&nbsp;</p>


<p>You may also schedule service or request a quote online.&nbsp; Simply fill
out the form below and shortly after you will receive a call from us!</p>

</td>
</tr>
</table>

<p align="left">

<p align="left">

<p align="left">

<p align="left">
<form method="POST" action="success.php" enctype="text/plain">
<table border="1" cellpadding="20" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" id="AutoNumber4" bgcolor="#6699FF">
<tr>
<td width="100%" bordercolor="#6699FF"><b>Request Form</b><fieldset style="padding: 2">
<br>
<legend>I would like to: </legend>
<input type="radio" value="service" name="type" checked>&nbsp; Schedule
Service
<input type="radio" name="type" value="quote">&nbsp; Request a Quote</fieldset><p>&nbsp;</p>
<fieldset style="padding: 2">
<legend>I need the work done on:</legend>
Date:&nbsp; <select size="1" name="month">
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>&nbsp;&nbsp;&nbsp; <select size="1" name="day">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select><p align="left">at Time:&nbsp;&nbsp;&nbsp;
<input type="radio" value="morning" name="time" checked> Morning (8am-11am)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="time" value="noon"> Noon (11am-1pm)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="time" value="afternoon">Afternoon (1pm-4pm)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="time" value="na">No Preference<br>
</p>
</fieldset><p>Description of the Job:</p>
<p><textarea rows="5" name="description" cols="44"></textarea></p>
<p>Special Comments:</p>
<p><textarea rows="5" name="comments" cols="44"></textarea></p>
<p>&nbsp;</p>
<p><b>Contact Information</b></p>
<p>Name:&nbsp;&nbsp;&nbsp; <input type="text" name="name" size="30"></p>
<p>Address Line 1:&nbsp;&nbsp;&nbsp;
<input type="text" name="address1" size="30"></p>
<p>Address Line 2:&nbsp;&nbsp;&nbsp;
<input type="text" name="address2" size="30"></p>
<p>City:&nbsp;&nbsp;&nbsp; <input type="text" name="city" size="30"></p>
<p>State:&nbsp;&nbsp;&nbsp; <select size="1" name="state">
<option>AB</option>
<option>AL</option>
<option>AK</option>
<option>AR</option>
<option>AZ</option>
<option>BC</option>
<option>CA</option>
<option>CO</option>
<option>CT</option>
<option>DC</option>
<option>DE</option>
<option>FL</option>
<option>GA</option>
<option>HI</option>
<option>IA</option>
<option>ID</option>
<option>IL</option>
<option>IN</option>
<option>KS</option>
<option>KY</option>
<option>LA</option>
<option>MA</option>
<option>MB</option>
<option>MD</option>
<option>ME</option>
<option>MI</option>
<option>MN</option>
<option>MO</option>
<option>MS</option>
<option>MT</option>
<option>NB</option>
<option>NC</option>
<option>ND</option>
<option>NE</option>
<option>NF</option>
<option>NH</option>
<option>NJ</option>
<option>NM</option>
<option>NS</option>
<option>NT</option>
<option>NV</option>
<option selected>NY</option>
<option>OH</option>
<option>OK</option>
<option>ON</option>
<option>OR</option>
<option>PA</option>
<option>QC</option>
<option>RI</option>
<option>SC</option>
<option>SD</option>
<option>SK</option>
<option>TN</option>
<option>TX</option>
<option>UT</option>
<option>VA</option>
<option>VT</option>
<option>WA</option>
<option>WI</option>
<option>WV</option>
<option>WY</option>
<option>YT</option>
</select></p>
<p>Zip Code:&nbsp;&nbsp;&nbsp;
<input type="text" name="zip" size="20"></p>
<p>Phone Number:&nbsp;&nbsp;&nbsp;
<input type="text" name="phone" size="20"></p>
<p>&nbsp;</p>
<p align="center"><input type="submit" value="Submit"><input type="reset" value="Reset"></p>
</td>
</tr>
</table>
</form>

</body>

</html>



the code for success.php is:


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="content" content="plumbing, heating, hvac, cooling, new work, service call, repair, renovation, mulco, quogue, long island, suffolk county plumber">
<meta name="author" content="mulco plumbing, mulco heating, mulco mechanical, quogue, long island, suffolk county, new york">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Success</title>
<meta name="Microsoft Border" content="tlb">
</head>

<body>

<script language="php">
$type = $_POST['type'] ;
$month = $_POST['month'] ;
$day = $_POST['day'] ;
$time = $_POST['time'] ;
$description = $_POST['description'] ;
$comments = $_POST['comments'] ;
$name = $_POST['name'] ;
$message = $month ;

{mail("email@optonline.net", "Feedback Form Results",
$message, $name);}
</script>

<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="690" id="AutoNumber4">
<tr>
<td><font size="7">Success!</font><p><font size="4">We have received your
inquiry and will get back to you shortly.&nbsp; Please <a href="index.htm">
click here</a> to go back.</font></td>

</tr>
</table>

</body>

</html>


I am building the site in frontpage (all the header tags), and I can't build the form in frontpage because front page extensions are not enabled on my server.

So what should happen is I get an email with the month being displayed as the body of my message, however the message is blank. I receive an email very quickly with a subject line of Feedback Form Results and the return address is anonymous from my host. However the body of the email is blank.

If i change $message to some text like:

$message = "message"

then I get an email with message displayed in the body, but none of the variables will show anything. Please help!

PappaJohn
08-10-2007, 05:17 PM
You have no values set for the <option> elements, so the form has no values to pass to success.php.

You'll need to set a value for each of them like this:


<option value="January">January</option>


Also, your code has no error checking for the inputs, and spammers will love your form. You might want to google for email header injections.

stoli7188
08-10-2007, 06:22 PM
thanks for your help, i will add the value field for the form and Ill take your advice and google the headers.. thanks

stoli7188
08-10-2007, 07:15 PM
I added some values and I am still not getting anything in the email when I try to display $month.. heres the modification I made to the code above.


<option value="Jan">January</option>
<option value="Feb">February</option>
<option value="Mar">March</option>
<option value="Apr">April</option>
<option value="May">May</option>
<option value="Jun">June</option>
<option value="Jul">July</option>
<option value="Aug">August</option>
<option value="Sep">September</option>
<option value="Oct">October</option>
<option value="Nov">November</option>
<option value="Dec">December</option>

CFMaBiSmAd
08-10-2007, 07:54 PM
Take the following out of your <form tag - enctype="text/plain"

This prevents PHP from receiving any form data.

stoli7188
08-10-2007, 07:58 PM
thanks for the quick response, I took the tag out.. and now its working. Thank you for your help. Now i just need to make the message look pretty ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum