Hi,
I have added a little area on my site where users can add comments. The comments get sent to the db and are displayed on the page. This is done by a simple form that links to a php page with this code:
<?
include(‘../../functions.php’);
$name=$_POST[‘name’];
$company =$
$email=$_POST[’email’];
$comment=$
$optin=$_POST[‘optin’];
// Connect to the MySQL DB server.
// calls function from functions.php to connect to the database.
connectToDB();
// Assign the SQL statement to the variable $query.
$query = “INSERT INTO forum_comments VALUES (”,’$name’,’$company’,’$email’, ‘$comment’, CURDATE(), ‘$optin’, ‘1’)”;
//Execute the query on the database.
mysql_query($query);
//Close the connection with the DB.
mysql_close();
header(‘Location: ../../forum.php’);
?>
For some reason, about every one time in ten, the data doesn’t get added to the db. I can’t understand why as it seems to be an intermittent fault.
Can anyone give any advice on why this may be happening?
Is there a way to make the code wait for a confirmation from the db, before redirecting back to the comment page?
Thanks in advance.