I have a site that im trying to put together and need some help with a checkbox. I have a form where the user enters data and when the user is finished they click on the submit btn witch populates the database. I want to enter a check box into the form that the user will check if they want to. My problem is understanding the whole check box this with the database. I made a field in the table that is a tinyint. I just need the to figure out the php code that goes into the form to update the database.
<html>
<head>
<basefont face="Arial">
</head>
<body bgcolor="white">
<?php
$intPriceBasedOn = (int) $_POST['PriceBasedOn'];
if (!isset($_POST['submit'])) {
// form not submitted
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<p>School:
<input type="text" name="School">
<br>
Teacher: <input type="text" name="Teacher">
<br>
First Contact Start: <input type="text" name="dtFirstContactSt" maxlength="10" size="10">
<br>
Development Start: <input type="text" value= "yyyy-mm-dd" name="dtDevelopmentSt" maxlength="10" size="10">
<br>
Development End: <input type="text" value= "yyyy-mm-dd" name="dtDevelopmentEnd" maxlength="10" size="10">
<br>
Pricing Start: <input type="text" value= "yyyy-mm-dd" name="dtPricingSt" maxlength="10" size="10">
<br>
Pricing End: <input type="text" value= "yyyy-mm-dd" name="dtPricingEnd" maxlength="10" size="10">
<br>
Marketing Start: <input type="text" value= "yyyy-mm-dd" name="dtMarketingSt" maxlength="10" size="10">
<br>
Price Based On: <?php echo "<select name=\"PriceBasedOn\">\n";
for( $i=0; $i<=75; $i++) {
echo "<option value=\"$i\">$i</option>\n";
}
echo "</select>";
?>
<br>
Trip Assigned To: <input type="text" value= "" name="TripAssignedTo" maxlength="2" size="10">
<br>
TripMade:<input type="checkbox" name="TripMade">
<br>
Notes:
<textarea rows="3" cols="40" name="Notes"></textarea>
<br>
<input type="submit" name="submit" ONCLICK="window.location.href='http://www.integranite.net/EAToursDemo/welcome.php'">
<input type="reset" name="reset">
<INPUT TYPE="BUTTON" VALUE="Home" ONCLICK="window.location.href='http://www.integranite.net/EAToursDemo/welcome.php'">
</form>
<?php
}
else {
// form submitted
// set server access variables
$host="localhost";
$username="xxx";
$password="xxx";
$database="xxx";
// get form input
// check to make sure it's all there
// escape input values for greater safety
$School = empty($_POST['School']) ? die ("ERROR: Enter a School") : mysql_escape_string($_POST['School']);
$Teacher = empty($_POST['Teacher']) ? die ("ERROR: Enter an Teacher") : mysql_escape_string($_POST['Teacher']);
$dtFirstContactSt= mysql_escape_string($_POST['dtFirstContactSt']);
$dtDevelopmentSt= mysql_escape_string($_POST['dtDevelopmentSt']);
$dtDevelopmentEnd= mysql_escape_string($_POST['dtDevelopmentEnd']);
$dtPricingSt= mysql_escape_string($_POST['dtPricingSt']);
$dtPricingEnd= mysql_escape_string($_POST['dtPricingEnd']);
$dtMarketingSt= mysql_escape_string($_POST['dtMarketingSt']);
$TripAssignedTo= empty($_POST['TripAssignedTo']) ? die ("ERROR: Enter Initials for Trip Assigned To") : mysql_escape_string($_POST['TripAssignedTo']);
$Notes= mysql_escape_string($_POST['Notes']);
// open connection
$connection = mysql_connect($host, $username, $password) or die ("Unable to connect!");
// select database
mysql_select_db($database) or die ("Unable to select database!");
// create query
$query = "INSERT INTO Project1 (School, Teacher, dtFirstContactSt, dtFirstContactEnd, dtDevelopmentSt, dtDevelopmentEnd, dtPricingSt, dtPricingEnd, dtMarketingSt, dtMarketingEnd, TripAssignedTo, Notes, PriceBasedOn) VALUES ('$School', '$Teacher', '$dtFirstContactSt', '$dtFirstContactEnd', '$dtDevelopmentSt', '$dtDevelopmentEnd', '$dtPricingSt', '$dtPricingEnd', '$dtMarketingSt', '$dtMarketingEnd', '$TripAssignedTo', '$Notes', $intPriceBasedOn)";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// print message with ID of inserted record
echo '<a href="welcome.php" class ="licitate"> Info Added. Click to Return Home</a>';
// close connection
mysql_close($connection);
}
?>
<FORM METHOD="LINK" ACTION="http://www.integranite.net/EAToursDemo/welcome.php">
</FORM>
</body>
</html>