hi all,
I need some help with this page:
[php]<?php
session_start();
include_once(’…/includes/connection.php’);
include_once(’…/includes/article.php’);
if ( isset($_GET[‘edit’]) )
{
$id = $_GET[‘edit’];
$res = mysql_query(“SELECT * FROM article_content WHERE id=’$id’”);
$row - mysql_fetch_array($res);
}
$article = new Article;
if (isset($_SESSION[‘logged_in’])) {
if (isset($_GET[‘id’])) {
$id = $_GET[‘id’];
$query = $pdo->prepare(‘SELECT FROM articles WHERE article_id =?’);
$query->bindValue(1, $id);
$query->execute();
header('Location: edit.php');
}
$articles = $article->fetch_all();
?>
Edit Article
<?php if (isset($error)) { ?><small style="color:#aa0000"><?php echo $error; ?>
<?php } ?>
<form action="edit.php" method="post">
<?php foreach ($articles as $article) { ?>
ID: <input type="text" name="id" value="<?php echo $article['article_id']; ?>"><br /><br />
Article Title: <b><?php echo $article['article_title']; ?></b> <br /><br />
Text: <br/> <textarea rows="15" name="article_content" cols="50"><?php echo $article['article_content']; ?></textarea><br /><br />
<input type="submit" value="Edit Article"> <br/ >
<?php }
if( isset($_POST['article_content']))
{
$newcontent = $_POST['article_content'];
$id = $_POST['id'];
$query = $pdo->query("UPDATE article_content SET article_content='$newcontent' WHERE id='$id'");
}
?>
</form>
<?php
} else {
header('Location: index.php');
}
?>[/php]
The problem is that the database doesnt get updated.
Here is a screenshot of my database: