Need help with code [Archive] - SpeedGuide.net Broadband Community

View Full Version : Need help with code


Roody
03-06-08, 02:12 PM
I am having issues with my code. If you take a look at this page here. (http://www.chbs.org/school/contact.php)

When a person submits their information we are receiving info from all fields except City and State. Any ideas on what is wrong with my code below?

<td><form action="sendmail.php" method="post" name="form1" style="margin-bottom: 0;">
<table width="901" border="0" cellpadding="0" bordercolor="#000000">
<tr>
<td width="9%">Name</td>
<td colspan="3"><input name="Name" type="text" id="Name"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td>Email</td>
<td colspan="3"><input name="Email" type="text" id="Email"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td>Address</td>
<td colspan="3"><input name="Address" type="text" id="Address"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td>City</td>
<td width="26%"><input name="City" type="text" id="City"></td>
<td width="6%">State</td>
<td width="59%"><input name="State" type="text" id="State"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td>Zip Code</td>
<td><input name="Zip" type="text" id="Zip"></td>
<td>Phone</td>
<td><input name="Phone" type="text" id="Phone"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Request Brochure</td>
<td><select name="Brochure" id="Brochure">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td valign="top">Comments</td>
<td colspan="3"><textarea name="Comments" cols="60" rows="5" id="Comments"></textarea></td>
</tr>
<tr>
<td valign="top">&nbsp;</td>
<td colspan="3"><input name="Submit" type="submit" value="Submit"></td>
</tr>
<tr>
<td valign="top">&nbsp;</td>
<td colspan="3"><font size="1"><font size="1">
<?php include("footer.php"); ?>
</font></font></td>
</tr>
</table>
</form></td>

stevebakh
03-06-08, 05:45 PM
The problem isn't with the HTML. Your problem lies with the server side code in the sendmail.php file. It's likely something very simple, like a misspelling, or the state and city post vars not being grabbed. If you have access to the PHP file, look in there, or share it here (don't forget to remove any sensitive data or passwords if they are included in the file).

Also, on a slightly unrelated note, you shouldn't be using tables to layout your pages or forms - it breaks accessibility and it's just semantically wrong. :p

By the way, you can check what's being sent to the server from your browser with a really nifty addon called HTTP Live Headers, found here: https://addons.mozilla.org/en-US/firefox/addon/3829

You can see headers and the Generator tab will show you what's sent and received (great to check that POST sends actually send all the data you want). Firebug and the Web Developer toolbar are great too.

Roody
03-06-08, 08:21 PM
Ok thanks man. I don't have the file on my computer here at home, but I will post it tomorrow. :)

-EDIT-

How does the addon work? I installed it in FF, but I am not understanding how to use it? :confused:

Roody
03-07-08, 07:53 AM
Ok here is the sendmail.php file with my email addy removed for privacy purposes.

<?
$body="
NAME: $Name
ADDRESS: $Address
CITY/STATE: $City_State
ZIP: $Zip
PHONE: $Phone
BROCHURE: $Brochure
COMMENTS: $Comments
";
$toemail="email removed by Roody";
mail(Feedback." <".$toemail.">","Contact Page Results", $body, "From: ".$Name." <".$Email.">");
header( "Location: http://www.chbs.org/index.php" );
?>

Roody
03-07-08, 08:03 AM
Just got it fixed. I dropped the City_State so it was seperate and that fixed it. :)

TonyT
03-07-08, 08:39 AM
Use this for city & state in your form (much more pro):
//get form values into local variables & format message body
$space = ", ";
$City_State = $city . $space . $state;
$body="
NAME: $Name
ADDRESS: $Address
CITY/STATE: $City_State
ZIP: $Zip
PHONE: $Phone
BROCHURE: $Brochure
COMMENTS: $Comments
";

City: <input type="text" name="city" size="30" value=""><br />
State: <select name="state" size="1">
<option></option>
<option value="DC">District of Columbia</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option></select>

Roody
03-07-08, 08:50 AM
Ok thanks Tony. I will look into that.

stevebakh
03-07-08, 01:38 PM
Roody, regarding the addon, you view it by going to the Tools menu, then selecting Live HTTP Headers. The Generator tab in there is the one you can use to see sends and receives.

Roody
03-07-08, 01:40 PM
Ok thanks. I appreciate that. :)