Jump to content

Page Reload


lmhart

Recommended Posts

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

<?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>

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

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

 

refresh.php

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

 

list.php

<?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 />";
   }

?>

Link to comment
https://forums.phpfreaks.com/topic/177819-page-reload/
Share on other sites

refresh.php, problem

 

no timelimit is said, and you are refreshing it to the refresh page.

 

most browsers will ignore it 1) because it redirects to the same page

2) because its a loop.

 

solution

 

<?php
header('location: mypage.php');
?>

 

and you can google the refresh one, it does have a timer that goes with it (eg x seconds)

Link to comment
https://forums.phpfreaks.com/topic/177819-page-reload/#findComment-937740
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.