strangely enough I got this to work once but I can't understand how. I've looked it over for hours. need help.
here's the situation.
all I want to do is have my form, a basic form, insert information into my database. It works for all my fields, except two. I get no errors, no messages. It just doesn't register in my database. All the other fields, as I said, register fine. anyone know why this would do this? here are my two pages that the problem should be rooted in...Thanks in advance:
reg.php
<?php
include("config.php");
// Get data from form
if($formMethod == "post") {
$first = $_POST['first'];
$last = $_POST['last'];
$age = $_POST['age'];
$city = $_POST['city'];
$state = $_POST['state'];
$fifteen = $_POST['fifteen'];
$fifteenl = $_POST['fifteenl'];
$fifteend = $_POST['fifteend'];
$mile = $_POST['mile'];
$five = $_POST['fivek'];
$ten = $_POST['tenk'];
$half = $_POST['half'];
$full = $_POST['full'];
}
else {
$first = $_GET['first'];
$last = $_GET['last'];
$age = $_GET['age'];
$city = $_GET['city'];
$state = $_GET['state'];
$fifteen = $_GET['fifteen'];
$fifteenl = $_GET['fifteenl'];
$fifteend = $_GET['fifteend'];
$mile = $_GET['mile'];
$five = $_GET['fivek'];
$ten = $_GET['tenk'];
$half = $_GET['half'];
$full = $_GET['full'];
}
// Remove HTML-tags and unnecessary spaces
$first = rtrim(ltrim(strip_tags($first)));
$last = rtrim(ltrim(strip_tags($last)));
$age = rtrim(ltrim(strip_tags($age)));
$city = rtrim(ltrim(strip_tags($city)));
$state = rtrim(ltrim(strip_tags($state)));
$fifteen = rtrim(ltrim(strip_tags($fifteen)));
$fifteenl = rtrim(ltrim(strip_tags($fifteenl)));
$fifteend = rtrim(ltrim(strip_tags($fifteend)));
$mile = rtrim(ltrim(strip_tags($mile)));
$five = rtrim(ltrim(strip_tags($five)));
$eight = rtrim(ltrim(strip_tags($eight)));
$ten = rtrim(ltrim(strip_tags($ten)));
$half = rtrim(ltrim(strip_tags($half)));
$full = rtrim(ltrim(strip_tags($full)));
// Check that none of the fields are empty
if (empty($first) || empty($last) || empty($age) || empty($city) || empty($state)) {
echo "One or more fields are missing information."; }
else {
// Connect to MySQL
mysql_connect($mySQLhost, $mySQLuser, $mySQLpass)
or die("Could not connect: " . mysql_error());
mysql_select_db($mySQLdb);
// Insert the data into the database
if (mysql_query("INSERT INTO $mySQLtable (first,last,age,city,state,fifteen[B],fifteenl,fifteend,[/B]mile,fivek,tenk,half,full) VALUES ('$first','$last','$age','$city','$state','$fifteen','$fifteenl','$fifteend','$mile','$five','$ten','$half','$full')")) {
echo $regSuccess; }
else { echo $regFailed ;}
mysql_close(); }
echo "<p><a href='$pathList'>View current list of participants</a></p>";
?>
index.php
<?php
include("config.php");
echo "<form action='$regScript' method='$formMethod' name='form'>";
?>
<label><span>First Name*</span>
<input type='text' name='first' id='first' class='input-text'/>
</label>
<label><span>Last Name*</span>
<input type='text' name='last' id='last' class='input-text'/>
</label>
<label><span>Age*</span>
<input type='text' name='age' id='age' class='input-text'/>
</label>
<label><span>City*</span>
<input type='text' name='city' id='city' class='input-text'/>
</label>
<label><span>State*</span>
<select name='state' id='state' class='selectInput'>
<option value="">where do you live?</option>
<option value="-1">Other</option>
<option value='AK'>Alaska</option>
<option value="AL">Alabama</option>
<option value="AR">Arkansas</option>
<option value="AZ">Arizona</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DC">District of Columbia</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="IA">Iowa</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option><option value="KS">Kansas</option><option value="KY">Kentucky</option><option value="LA">Louisiana</option><option value="MA">Massachusetts</option><option value="MD">Maryland</option><option value="ME">Maine</option><option value="MI">Michigan</option><option value="MN">Minnesota</option><option value="MO">Missouri</option><option value="MS">Mississippi</option><option value="MT">Montana</option><option value="NC">North Carolina</option><option value="ND">North Dakota</option><option value="NE">Nebraska</option><option value="NH">New Hampshire</option><option value="NJ">New Jersey</option><option value="NM">New Mexico</option><option value="NV">Nevada</option><option value="NY">New York</option><option value="OH">Ohio</option><option value="OK">Oklahoma</option><option value="OR">Oregon</option><option value="PA">Pennsylvania</option><option value="PR">Puerto Rico</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="VA">Virginia</option><option value="VT">Vermont</option><option value="WA">Washington</option><option value="WI">Wisconsin</option><option value="WV">West Virginia</option><option value="WY">Wyoming</option>
</select>
</label>
<br>
<br>
<table>
<tr valign="top">
<td><label for="event" id="event"style="font-size:28px;padding-right:5px">1500m:</label><br /></td>
<td><label for="txtdistance">TIME:</label><br /><input type="text" name="fifteen" title="" id="time" size="5" class='input-text' /></td>
[B]<td><label for="txttime">LOCATION:</label><br /><input type="text" name="fifteenl" title="" id="fifteenl" size="5"class='input-text' /></td>
<td><label for="txtlocation">DATE:</label><br /><input type="text" name="fifteend" title="" id="fifteend" size="5"class='input-text' /></td>[/B]
</tr>
</table>
<label><span class='label'>Mile</span>
<input type='text' name='mile' id='time' class='input-text'/>
</label>
<label><span class='label'>5k</span>
<input type='text' name='fivek' id='time' class='input-text'/>
</label>
<label><span class='label'>10k</span>
<input type='text' name='tenk' id='time' class='input-text'/>
</label>
<label><span class='label'>Half</span>
<input type='text' name='half' id='time' class='input-text'/>
</label>
<label><span class='label'>Full</span>
<input type='text' name='full' id='time' class='input-text'/>
</label>
<input name='submit' type='submit' class='button'value='post it!'>
</form>
<p></p>
</div>
</div>
</body>
</html>
I've highlighted the fields that aren't working. The fields are: fifteenl & fifteend
(standing for 1500 Location and 1500 Date)
Like I said, all other fields work fine.
Any theories?
Thanks!