|
1)
First off, it seems like you need to be putting your insert statement inside the 'if($error==0)' brackets. Now, it is trying to insert the data even if the form validation fails.
2)
The header issue, headers have to be set before ANYTHING is sent to the browser. I believe ANYTHING includes html as well.
Again, it seems like the header location change needs to take place inside the 'if($error==0)' brackets. It is trying to redirect whether the form fails or passes.
3)
You will probably want to use an argument like:
if ( updating )
{
update database
}
else
{
insert new record into database
}
4)
As for the query not working. The syntax looks correct. Are you getting any errors? Try adding an or die() at the end so you can catch any mysql errors. It would be like this:
mysql_query ( $query ) or die ( mysql_error ( ) );
|