sorry to say this is my first php project but i am used to using actionscript so i'm not new to scripting languages. i don't seem to be the only one who has trouble with checkboxes
the data input into the text fields is uploaded to the MYSQL database fine but the checkbox values are not, there is no obvious reason i can see below is the entire code from the file which is intended to add data for a new venue to the database, basic i know but functionality comes first.
Code: Select all
<?php
$hostname = "localhost";
$db_user = "********";
$db_password = "*******";
$database = "********";
$db_table = "********";
//connect to mysql
$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($database,$db);
?>
<html>
<head>
<title>test venue form</title>
</head>
<body>
<?php
if (isset($_REQUEST['Submit'])) {
# THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE
$sql = "INSERT INTO $db_table(name,summary,email,location,min_guests,max_guests,price,festive,themed,party_types,key_features,details,optional_extras,description,venue_image,enabled)
values ('".mysql_real_escape_string(stripslashes($_REQUEST['name']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['summary']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['email']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['location']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['min_guests']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['max_guests']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['price']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['festive']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['themed']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['party_types']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['key_features']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['details']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['optional_extras']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['description']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['venue_image']))."',
'".mysql_real_escape_string(stripslashes($_REQUEST['enabled']))."')";
if($result = mysql_query($sql ,$db)) {
echo '<h1>Thank you</h1>Your information has been entered into our database<br><br><img src="http://www.webune.com/images/headers/default_logo.jpg"';
} else {
echo "ERROR: ".mysql_error();
}
} else {
?>
<form method="post" action="">
Name:
<br>
<input type="text" name="name">
<br>
Summary:
<br>
<input type="text" name="summary">
<br>
Email:
<br>
<input type="text" name="email">
<br>
Location:
<br>
<input type="text" name="location">
<br>
Guests Min:
<br>
<input type="text" name="min_guests">
<br>
Guests Max:
<br>
<input type="text" name="max_guests">
<br>
Price:
<br>
<input type="text" name="price">
<br>
Festive:
<br>
<input type="checkbox" name="festive" value="1">
<br>
Themed:
<br>
<input type="checkbox" name="themed" value="1">
<br>
Party Types:
<br>
<input type="text" name="party_types">
<br>
Key Features:
<br>
<input type="text" name="key_features">
<br>
Details:
<br>
<input type="text" name="details">
<br>
Optional Extras:
<br>
<input type="text" name="optional_extras">
<br>
Description:
<br>
<input type="text" name="description">
<br>
Venue Image:
<br>
<input type="text" name="venue_image">
<br>
Enabled:
<br>
<input type="checkbox" name="enabled" value="1">
<br>
<br>
<input type="submit" name="Submit" value="Submit">
</form>
<br>
<br>
<form>
<input type="button" value="Back" onClick="parent.location='http://www.teztez.co.uk/myparty/newentry.html'">
</form>
<?php
}
?>
</body>
</html>
many thanks
- Tez Grant