Jump to content

[SOLVED] news update


Sooth

Recommended Posts

Hi! I made this code to edit news on an website. The query looks OK, but it is not updating the news.

 

<?php
session_start();
include "config.inc.php";
include "header.inc.php";
?>

<h1>Admin » News » Edit</h1>
<?php
if($_SESSION[admin]) {
?>
<?php include "admin_menu.inc.php"; ?>
<?php
if($_POST[e]) {
mysql_connect($db_hostname,$db_username,$db_password);
@mysql_select_db($db_error); 
$query="UPDATE news SET title='$_POST[title]', content='$_POST[content]' WHERE id='$_GET[n]'";
mysql_query($query);
mysql_close();
echo "<p>News updated.</p>";
}
else {
mysql_connect($db_hostname,$db_username,$db_password);
@mysql_select_db($db_database)or die($db_error);
$query="SELECT * FROM news WHERE id='$_GET[n]'";
$result=mysql_query($query);mysql_close();
while($row=mysql_fetch_array($result))
{?>
<form action="<?php echo $site_address; ?>admin/news/edit/<?php echo $_GET[n]; ?>/" method="post">
<p>Title</p>
<p><input type="text" name="title" value="<?php echo $row[title]; ?>" style="width: 200px;" /></p>
<p>Content</p>
<p><textarea name="content" cols="100" rows="10"><?php echo $row[content]; ?></textarea></p>
<p><input type="hidden" name="e" value="1" /><input type="submit" value="OK" /></p>
</form>
<?php
}
}
}
else echo "<p>You must be an Administrator to view this page.</p>";
?>

<?php
include "footer.inc.php";
?>

 

The URLs are rewritted and ...news/edit/xxxx/ becomes ...edit.php?n=xxxx, so the problem isn't at the $_GET[n] neither.

 

I've made a similar page to write news and it works perfectly.

 

What could be wrong?

Link to comment
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.