Jump to content

Recommended Posts

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]
Link to comment
https://forums.phpfreaks.com/topic/10470-edit-news-help/
Share on other sites

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"])

Link to comment
https://forums.phpfreaks.com/topic/10470-edit-news-help/#findComment-39073
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.