Hey,
I have the following code, where i firstly select from a datase to populate a textarea box, which is within a form. It also has an update button. Now when the update button(btn-update) is clicked i have an UPDATE statement which updates the database.
Now the problem i have is, the UPDATE works perfectly, but i direct back to the same page upon clicking update, and the changed do not update the text box, i have to refresh the page or even navigate to another page and back to see the change..
The update works fine but the textbox shows the changes if i reload the page, why is this?
Heres the code:-
PHP Code:<?php
$dbc = //database connection
$query = "SELECT content FROM tbl_homepage";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
?>
<form action="" method="post">
<table cellspacing="5" style="margin-top:10px">
<tr><td><h4>Steve Tappin Panel</h4></td></tr>
<tr><td><textarea name="txt_content" style="width: 589px; height: 181px"><?php echo $row['content'] ?></textarea></td></tr>
<tr><td><input type="submit" name="btn-update" value="update details"/></td></tr>
</table>
</form>
<?php
if (isset($_POST['btn-update']))
{
if ($_POST['txt_content'] == "")
{
echo "<p>You did not complete all of the required fields.</p>";
}
else
{
$content = mysql_real_escape_string($_POST['txt_content']);
$insert = "UPDATE tbl_homepage SET content = '$content'";
$add_member = mysql_query($insert);
header("Location: http://www.xinfu.com/admin/manage-homepage.php");
}
}
?>





Bookmarks