chrislukehowell Posted December 15, 2009 Share Posted December 15, 2009 First of all i'd just like to mention that the captchas on this website are so hard to read it took me ages to register! Anyway... I recently made a content management system, or tried to, using some tutorials i found, and everything worked perfectly really, I could submit new posts, they'd go to the database then appear on my index page, but since coming back to it and reopening it it just won't submit the posts anymore. I am very new to php so it could be a really simple error and im just overlooking something but I cant figure it out. The Add content script it... <?php // connect to MySQL database here require_once "connect_to_mysql.php"; // Requiring date from forms on admin page $title = $_POST['title']; $body = $_POST['body']; // Build the sql command string $sqlCommand = "INSERT INTO cms_content (id, title, body) VALUES('$id','$title','$body')"; // Execute the query here now $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); // Attain the auto-incremented id field automatically if needed here $id = mysqli_insert_id($myConnection); // Echo output showing success and new user ID number echo "Posted Succesfully!"; // close mysql connection mysqli_close($myConnection); ?> I've got no idea where ive gone wrong really to be honest. Would be grateful if anyone can help Quote Link to comment https://forums.phpfreaks.com/topic/185269-form-not-submitting-information-to-the-database-but-displays-it-fine/ Share on other sites More sharing options...
sasa Posted December 15, 2009 Share Posted December 15, 2009 try to not insert id into database $sqlCommand = "INSERT INTO cms_content (title, body) VALUES('$title','$body')"; Quote Link to comment https://forums.phpfreaks.com/topic/185269-form-not-submitting-information-to-the-database-but-displays-it-fine/#findComment-978027 Share on other sites More sharing options...
chrislukehowell Posted December 15, 2009 Author Share Posted December 15, 2009 Strangely enough I took that out, got an error message, then put the i.d back in and it started working perfectly again. I think it might be something to do with xxamp. Thanks for your reply though! Quote Link to comment https://forums.phpfreaks.com/topic/185269-form-not-submitting-information-to-the-database-but-displays-it-fine/#findComment-978079 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.