Hello,
I have a simple Database setup to store events. However, the code I have does not work right. When entering in info into the forms, it should say "info entered in successfully..." however, when I press submit, it just blanks the form as if reloading the page. I don't get any errors, just a blank form. I was wondering if someone could take a quick look at my code and maybe figure out why it isn't working.
Thanks,
Chris
Here's the code (I X'd out the password):
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<?php
if ($submit) {
//Process the form
$db=mysql_connect("localhost","events","XXXXX");
mysql_select_db("events",$db) //select DB and connect to Server
OR DIE ("Unable to connect to Server!");
$sql="INSERT INTO events(name,date,body) VALUES('$name','$date','$body')";
$result=mysql_query($sql); //query the database
echo "Thank you! Event has been entered successfully! \n";
}else{
//display form
?>
<form method="post" action="<?php echo $PHP_SELF?>" name="events">
<p><b><font face="Arial, Helvetica, sans-serif" color="#0033CC">Event Management</font></b><br>
<br>
Event Name: <br>
<input type="text" name="name" size="75">
</p>
<p>Event Date:<br>
<input type="text" name="date">
</p>
<p>Event Description:<br>
<textarea name="body" cols="100" rows="15"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
</p>
</form>
<?php
} //end if
?>
</body>