Guteman Posted May 26, 2006 Share Posted May 26, 2006 I am making my own news script, but I seem to be stuck with this code trying to edit the news Im not getting Information updated echo.here is the code.[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<form action=admin-news.php method="post"><input type="hidden" name="cmd" value="edit"><table width=325 cellspacing=0 cellpadding=0 border=0 align=center><tr><td>Title:</td><td><input type="text" name="title" value="<?php echo $myrow["title"] ?>" size=30></td></tr><tr><td>Story:</td><td><textarea name="story" rows=5 cols=20><?php echo $myrow["story"] ?></textarea></td></tr><tr><td>Author:</td><td><input type="text" name="author" value="<?php echo $myrow["author"] ?>" size=30></td></tr><input type="hidden" name="cmd" value="edit"><tr><td colspan=2 align=center><br><input type="submit" name="submit" value="Submit"></td></tr></table></form><?php }if ($_POST["$submit"]) { $id = $_GET["id"]; $title = $_POST["title"]; $story = $_POST["story"]; $author = $_POST["author"]; mysql_query("UPDATE news SET title='$title' , story='$story' , author='$author' WHERE ID='$id'"); echo ("Thank you! Information updated."); }}?> [/quote] Quote Link to comment https://forums.phpfreaks.com/topic/10470-edit-news-help/ Share on other sites More sharing options...
hvle Posted May 26, 2006 Share Posted May 26, 2006 if ($_POST["$submit"]) should change to if ($_POST['submit'] == 'submit')or if (isset($_POST['submit']))I prefer the first one, it's safer.your old code would be fine if you define $submit before the if statement. like:$submit = 'submit';if ($_POST["$submit"]) Quote Link to comment https://forums.phpfreaks.com/topic/10470-edit-news-help/#findComment-39073 Share on other sites More sharing options...
Guteman Posted May 26, 2006 Author Share Posted May 26, 2006 still not working Quote Link to comment https://forums.phpfreaks.com/topic/10470-edit-news-help/#findComment-39295 Share on other sites More sharing options...
nogray Posted May 26, 2006 Share Posted May 26, 2006 You are not submitting the news id in your form "WHERE ID='$id'" add the id as a hidden filed and change$id = $_GET["id"];to$id = $_POST["id"]; Quote Link to comment https://forums.phpfreaks.com/topic/10470-edit-news-help/#findComment-39299 Share on other sites More sharing options...
Guteman Posted May 26, 2006 Author Share Posted May 26, 2006 fixed it, for some reason when I made my table for the mysql, I made it ID not id.. so it messed with alot of the coding I did. Quote Link to comment https://forums.phpfreaks.com/topic/10470-edit-news-help/#findComment-39338 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.