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. Link to comment https://forums.phpfreaks.com/topic/33523-posting-data-with-php-into-mysql/ 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. Link to comment https://forums.phpfreaks.com/topic/33523-posting-data-with-php-into-mysql/#findComment-156902 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, Link to comment https://forums.phpfreaks.com/topic/33523-posting-data-with-php-into-mysql/#findComment-156907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.