I tried to search for similar questions but couldn't find the answer. This is my code:
if (isset($_GET['id'])) {
$id = $_GET['id'];
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo $id;
}
?>
<form method="post" action="update_post.php">
<input type="text" name="post_title" value="<?php echo $post['post_title']; ?>"></br>
<input type="submit" name="submit" value="Update Post">
</form>
URL: localhost/.../update_post.php?id=3
All it does is check the URL for the ?id= value if its set. If yes, then assign that to variable $id and then when the post form is submitted echo that variable.. I got this error always:
Notice: Undefined variable: id in ...update_post.php on line 9
Thank you for helping me.