Page Reload

Posted on 16th Feb 2014 by admin

I am having issues getting a page to reload after I submit data to a database. This form should input data to a DB and then I want it to reload and list what is in database. I have gotten it to reload and list the data but it always lists everything through to the second to last entry. The most current entry does not get listed. I must refresh the page to get it to list.

main form
Code: [Select]<?php
include 'refresh.php'; //should refresh the page
include 'dbc.php'; //database connection
include 'list_categories.php'; //lists all the categories from the database
echo "<br />";
?>
<form name="form1" method="post" action="add_category.php">
Add Category : <input name="category" type="text" id="category"><input type="submit" name="submit" value="Submit"></p>
</form>

<form name="form2" method="post" action="delete_category.php">
Delete: <?php include 'get_categories.php'; ?><input type="submit" name="submit" value="Submit">
</form>



<a href="http://budget.themarkhart.com/delete_all_categories.php">Delete All</a>



<a href="menu.php">Menu</a>

refresh.php
Code: [Select]<?php
$page = $_SERVER['PHP_SELF'];
header("Refresh: url=$page");
?>

list.php
Code: [Select]<?php

include 'dbc.php';

$result = mysql_query("SELECT * FROM categories order by category ASC");

while($row = mysql_fetch_array($result))
{
echo $row['category'];
echo "<br />";
}

?>

Other forums