Jump to content

Edit News


Peosan

Recommended Posts

I have this edit news script, everything works, except when I press submit.

When I press it, it shows it's been successfully updates, however, the database is unchanged.

 

I've tried but no success. :')

Here's the code:

 

<?php 
include("include/database.php");

	if (isset($_POST['submitted'])) {
		$title = $_POST['title'];
		$newstext = $_POST['newstext'];
		$posted = $_POST['posted'];

		$query2 = "UPDATE news_post SET title='$title', newstext='$newstext', posted='$posted' WHERE id='$id'";
		$r2 = mysqli_query($dbc, $query2);
		echo'<h3>Thank you! The news has been UPDATES successfully! Please wait (3) seconds while we throw you to the index!'; 
		echo "<meta http-equiv=Refresh content=4;url=index.php>";
	}
		elseif(isset($_GET['id'])) {
		$query = "SELECT * FROM news_post WHERE id='$_GET[id]'";
		$r = mysqli_query($dbc, $query);
			while($myrow = mysqli_fetch_assoc($r)) {
				$title = $myrow["title"];
				$newstext = $myrow["newstext"];
				$posted = $myrow["posted"];
?>

Link to comment
https://forums.phpfreaks.com/topic/204563-edit-news/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.