When I enter input to every text box and try to submit, I get my php error
Please fill in the Text Fields.
I cannot find the php programming error that makes it think that I have a blank field. The db fields match the php. I would appreciate help in determining why it thinks I have a blank field. Here's the php code.
- Code: Select all
<?php // vols_add.php
/* This script adds a new record. */
// Define a page title and include the header:
define('TITLE', 'Add a Record');
include('vols_templates/vols_header.html');
print '<h2>Add a Record into the Database</h2>';
//print "<font color='red'>All Text Fields must be filled in.</font>";
// Restrict access to administrators only:
if (!is_administrator())
{
print '<h2>Access Denied!</h2><p class="error">You do not have permission to access this page.</p>';
exit();
}
// Check for a form submission:
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{ // Handle the form.
if ( !empty($_POST['Name']) && !empty($_POST['Email']) )
{
// Need the database connection:
include('vols_includes/vols_connect.php');
// Prepare the values for storing:
$id= mysql_real_escape_string(trim(strip_tags($_POST['id'])), $link);
$FullName = mysql_real_escape_string(trim(strip_tags($_POST['FullName'])), $link);
$Email = mysql_real_escape_string(trim(strip_tags($_POST['Email'])), $link);
$phone = mysql_real_escape_string(trim(strip_tags($_POST['phone'])), $link);
$address = mysql_real_escape_string(trim(strip_tags($_POST['address'])), $link);
$cell = mysql_real_escape_string(trim(strip_tags($_POST['cell'])), $link);
$Fax = mysql_real_escape_string(trim(strip_tags($_POST['Fax'])), $link);
$cityandzip = mysql_real_escape_string(trim(strip_tags($_POST['cityandzip'])), $link);
$available = mysql_real_escape_string(trim(strip_tags($_POST['available'])), $link);
$rel_experience = mysql_real_escape_string(trim(strip_tags($_POST['rel_experience'])), $link);
$why_volunteer = mysql_real_escape_string(trim(strip_tags($_POST['why_volunteer'])), $link);
$vol_before = mysql_real_escape_string(trim(strip_tags($_POST['vol_before'])), $link);
$query = "INSERT INTO vols (FullName, Email, phone, address, cell, Fax, cityandzip, available, rel_experience, why_volunteer, vol_before)
VALUES('$FullName', '$Email', '$phone', '$address', '$cell', '$Fax','$cityandzip', '$available', '$rel_experience', '$why_volunteer', '$vol_before')";
$r = mysql_query($query, $link);
if (mysql_affected_rows($link) == 1)
{
// Print a message:
print "\r\n<font color='blue'> Your Record has been added!</font>";
}else
{
print '<p class="error">Could not store the Record because:<br />' . mysql_error($link) . '.</p><p>The query being run was: ' . $query . '</p>';
}
// Close the connection:
mysql_close($link);
} else
{ // Failed to enter a Record.
print '<p class="error"> Please fill in the Text Fields.</p>';
}
} // End of submitted IF.
// Leave PHP and display the form:
?>
<form action="vols_add.php" method="post">
<table align="center">
<tr><td><font color='red'> All Text Fields must be filled in.</font></td>
<td> </td>
</tr>
<tr>
<td width="50%">Full Name:
<input type="text" name="FullName" id="FullName"></td>
<td>Email:
<input type="text" name="Email" id="Email"></td>
</tr>
<tr>
<td width="50%">Phone:
<input type="text" name="phone" id="phone"></td>
<td>Address:
<input name="address" type="text" id="address" size="30"></td>
</tr>
<tr>
<td width="50%">Cell Phone:
<input name="cell" type="text" id="cell" size="25"></td>
<td>Fax No.:
<input type="text" name="Fax" id="Fax"></td>
</tr>
<tr>
<td width="50%">City, State, Zip:
<input name="cityandzip" type="text" id="cityandzip" size="20"></td>
<td>Available; D/Hrs:
<input type="text" name="available" id="available"></td>
</tr>
</table>
<br>
<table align="center">
<tr>
<td align="center"><p>Related Experience <p>
<textarea name="rel_experience" id="textarea" cols="45" rows="5"></textarea>
</td>
</tr>
<tr>
<td align="center"><p>Why Do You Want to Volunteer? </p>
<textarea name="why_volunteer" id="textarea2" cols="45" rows="5"></textarea>
</tr>
<tr>
<td align="center"> <p>Have You Been a BCLA Volunteer Before? When? Please explain.</p>
<textarea name="vol_before" id="textarea3" cols="45" rows="5"></textarea>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Submit New Record" />
</form>