here's the code. help please
Code: Select all
<?php
session_start();
if(!session_is_registered('myusername')){
header("location:index.htm");
}
if (isset($_POST['submit'])) {
ob_start();
$host="localhost";
$username="root";
$password="8154646";
$db_name="sbaker";
$yearfield=$_POST['yearfield'];
$monthfield=$_POST['monthfield'];
$dayfield=$_POST['dayfield'];
$statefield=$_POST['statefield'];
if ($_POST['venuefield'] !== NULL) {
$venuefield=$_POST['venuefield'];
}else{
$error = 'Please enter a venue';
}
if ($_POST['cityfield'] !== NULL) {
$cityfield=$_POST['cityfield'];
}else{
$error = 'Please enter a city';
}
if ($_POST['playing'] !== NULL) {
$playing=$_POST['playing'];
}else{
$error = 'Please enter the other bands you are playing with';
}
if ($_POST['infofield'] !== NULL) {
$infofield=$_POST['infofield'];
}else{
$error = 'Please enter some show information';
}
if ($error == NULL) {
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql = "INSERT INTO Shows SET " .
"DATE='$yearfield-$monthfield-$dayfield', " .
"VENUE='$venuefield', " .
"CITY='$cityfield, $statefield', " .
"PLAYINGWITH='$playing', " .
"INFO='$infofield'";
if (mysql_query($sql)) {
echo("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td><div align='center'><font face='verdana' size='1' color='red'><b>Your new show information has been added!</b><br><br></font></div></td></tr></table>");
$yearfield=NULL;
$monthfield=NULL;
$dayfield=NULL;
$venuefield=NULL;
$infofield=NULL;
$playing=NULL;
$cityfield=NULL;
$statefield=NULL;
} else {
echo("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td><div align='center'><font face='verdana' size='1' color='red'><b>ERROR ADDING NEW SHOW INFORMATION</b><br><br></font></div></td></tr></table>");
}
ob_end_flush();
}else{
echo $error;
ob_end_flush();
}
}
?>