andygsy Posted January 9, 2007 Share Posted January 9, 2007 Hi,Can anyone tell me why the following 'gets' the data fine from the database but wont post back in when clicking on the submit within the form (named as 'save'):<?phprequire("inc/conn.php");if(! isset($_COOKIE['admin'] )) {header("Location: admin.php");}if(isset($_POST['save'])) {$itemTitle = $_POST['itemTitle'];$content = $_POST['content'];$category = $_POST['category'];$link = $_POST['link'];if(isset($_POST['itemID'])) {$itemID = $_POST['itemID'];$sql = "UPDATE items SET itemTitle = '" . $itemTitle . "', content = '" . $content . "', category = '" . $category . "', link = '" . $link. "' WHERE itemID = " . $itemID;if ($result = mysql_query($sql)) {header("Location: controlpanel.php");}}}if(isset($_GET['itemID']) ) {$itemID = $_GET['itemID'];$sql = "SELECT * FROM items WHERE itemID = " . $_GET['itemID'];if ($result = mysql_query($sql)) {$row = mysql_fetch_array($result);$itemTitle = $row['itemTitle'];$content = $row['content'];$category = $row['category'];$link = $row['link'];}}else{$name = 'new item';}?>Cheers for the help. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted January 9, 2007 Share Posted January 9, 2007 comment out the header and echo out the query. add the 'or die(mysql_error())' to teh mysql_query and see what goes wrong. Quote Link to comment Share on other sites More sharing options...
andygsy Posted January 9, 2007 Author Share Posted January 9, 2007 Hi,Thanks for the reply, I've commented out the header and add the php as suggested and the page displays the ID number for the record being viewed but when clicking submit the page loops (?) and nothing is posted into the database.Cheers, Quote Link to comment 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.