PHP - Header("location: Page.php"); Redirects To Page But Seems To Load Cached Version
I have a page with results from a query that displays that has a link (works fine - passes variables etc) that deletes that line item from a database. It goes to the delete.php and actually executes and removes the item from the database and then has the line header("Location: page.php"); which returns BACK to the page displaying the results. However, it shows the old results until I hit Refresh in the browser. Its like the header is redirecting to a cached version of the page.
NOTE: This script used to work fine untouched when we where on a shared hosting account. We JUST updates to VPS hosting by the same host. Now this problem has risen and I can't figure out what is wrong. From what I can guess is there is something in php.ini that is either not set, set or set wrong. Any help would be greatly appreciated.
Thanks.
Similar TutorialsHi, I have a div which reloads every 10 seconds but I want it so that if it equals something then redirect the whole page when at the moment it just loads the whole page in in the div but need the div as it stores all my variables, anyone know of anything else I can use? Thanks Hello everyone. I am writing this order/feedback form using a php script.
Every time i hit submit, the html page (that has the form inside) just reloads and does not perform the script
could anyone give me some pointers in my code the form/php?
I have made sure they are linked verbatim
I am a nube so please forgive my inexperience
Here is the form in the html , down below it is the corresponding php code for the form
I am writing the code for my options page in my wordpress theme. It was working for awhile and the next time i checked, it couldnt save. When i hit save, it redirects to options.php. When i remove the code for the social options it still doesnt work and yet it was working before i included that code. What could be the problem here is the code <?php /** * This function introduces a single theme menu option into the WordPress 'Appearance' * menu. */ function blueray_theme_menu() { add_theme_page( 'Blue Ray Theme', // The title to be displayed in the browser window for this page. 'Blue Ray Theme', // The text to be displayed for this menu item 'administrator', // Which type of users can see this menu item 'blueray_theme_menu', // The unique ID - that is, the slug - for this menu item 'blueray_theme_renderpage' // The name of the function to call when rendering the page for this menu ); } // end blueray_theme_menu add_action('admin_menu', 'blueray_theme_menu'); /** * Renders a simple page to display for the theme menu defined above. */ function blueray_theme_renderpage() { ?> <!-- Create a header in the default WordPress 'wrap' container --> <div class="wrap"> <!-- Add the icon to the page --> <div id="icon-themes" class="icon32"></div> <h2>Blue Ray Theme Options</h2> <!-- Make a call to the WordPress function for rendering errors when settings are saved. --> <?php settings_errors(); ?> <?php $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'display_options';?> <h2 class="nav-tab-wrapper"> <a href="" class="nav-tab <?php echo $active_tab == 'display_options' ? 'nav-tab-active' : ''; ?>">Display Options</a> <a href="" class="nav-tab <?php echo $active_tab == 'social_options' ? 'nav-tab-active' : ''; ?>">Social Options</a> </h2> <!-- Create the form that will be used to render our options --> <form method="post" action="options.php"> <?php if( $active_tab == 'display_options' ) { settings_fields( 'blueray_theme_display_options_page' ); do_settings_sections( 'blueray_theme_display_options_page' ); } else { settings_fields( 'blueray_theme_social_options_page' ); do_settings_sections( 'blueray_theme_social_options_page' ); } // end if/else submit_button(); ?> </form> </div><!-- /.wrap --> <?php } // end blueray_theme_renderpage function blueray_initialize_theme_options() { if( false == get_option( 'blueray_theme_display_options' ) ) { add_option( 'blueray_theme_display_options' ); } // end if // First, we register a section. This is necessary since all future options must belong to a add_settings_section( 'general_settings_section', // ID used to identify this section and with which to register options 'Display Options', // Title to be displayed on the administration page 'blueray_general_options_callback', // Callback used to render the description of the section 'blueray_theme_display_options_page' // Page on which to add this section of options ); // Next, we'll introduce the fields for toggling the visibility of content elements. add_settings_field( 'firstareatitle', // ID used to identify the field throughout the theme 'First Area Title', // The label to the left of the option interface element 'blueray_firstareatitle_callback', // The name of the function responsible for rendering the option interface 'blueray_theme_display_options_page', // The page on which this option will be displayed 'general_settings_section', // The name of the section to which this field belongs array( // The array of arguments to pass to the callback. In this case, just a description. 'First Area Title:' ) ); add_settings_field( 'firstareatext', 'First Area Text', 'blueray_firstareatext_callback', 'blueray_theme_display_options_page', 'general_settings_section', array( 'First Area Text:' ) ); add_settings_field( 'firstarealink', 'First Area Link', 'blueray_firstarealink_callback', 'blueray_theme_display_options_page', 'general_settings_section', array( 'First Area Link:' ) ); // Finally, we register the fields with WordPress register_setting( 'blueray_theme_display_options_page', 'blueray_theme_display_options_page' ); } // end blueray_initialize_theme_options add_action('admin_init', 'blueray_initialize_theme_options'); /* ------------------------------------------------------------------------ * * Section Callbacks * ------------------------------------------------------------------------ */ function blueray_general_options_callback() { echo '<p>Set up the front page options</p>'; } // end sandbox_general_options_callback /* ------------------------------------------------------------------------ * * Field Callbacks * ------------------------------------------------------------------------ */ function blueray_firstareatitle_callback($args) { // First, we read the options collection $options = get_option('blueray_theme_display_options_page'); // Next, we update the name attribute to access this element's ID in the context of the display options array // We also access the show_header element of the options collection in the call to the checked() helper function $html = '<input type="checkbox" id="firstareatitle" name="blueray_theme_display_options_page[firstareatitle]" value="1" ' . checked(1, $options['firstareatitle'], false) . '/>'; // Here, we'll take the first argument of the array and add it to a label next to the checkbox $html .= '<label for="firstareatitle"> ' . $args[0] . '</label>'; echo $html; } // end blueray_toggle_header_callback function blueray_firstareatext_callback($args) { $options = get_option('blueray_theme_display_options_page'); // Next, we update the name attribute to access this element's ID in the context of the display options array // We also access the show_header element of the options collection in the call to the checked() helper function $html = '<input type="checkbox" id="firstareatext" name="blueray_theme_display_options_page[firstareatext]" value="1" ' . checked(1, $options['firstareatext'], false) . '/>'; // Here, we'll take the first argument of the array and add it to a label next to the checkbox $html .= '<label for="firstareatext"> ' . $args[0] . '</label>'; echo $html; } // end blueray_toggle_content_callback function blueray_firstarealink_callback($args) { $options = get_option('blueray_theme_display_options_page'); // Next, we update the name attribute to access this element's ID in the context of the display options array // We also access the show_header element of the options collection in the call to the checked() helper function $html = '<input type="checkbox" id="firstarealink" name="blueray_theme_display_options_page[firstarealink]" value="1" ' . checked(1, $options['firstarealink'], false) . '/>'; // Here, we'll take the first argument of the array and add it to a label next to the checkbox $html .= '<label for="firstarealink"> ' . $args[0] . '</label>'; echo $html; } // end blueray_toggle_footer_callback /** * Initializes the theme's social options by registering the Sections, * Fields, and Settings. * * This function is registered with the 'admin_init' hook. */ function blueray_theme_intialize_social_options() { // If the social options don't exist, create them. if( false == get_option( 'blueray_theme_social_options' ) ) { add_option( 'blueray_theme_social_options' ); } // end if add_settings_section( 'social_settings_section', // ID used to identify this section and with which to register options 'Social Options', // Title to be displayed on the administration page 'blueray_social_options_callback', // Callback used to render the description of the section 'blueray_theme_social_options_page' // Page on which to add this section of options ); add_settings_field( 'twitter', 'Twitter', 'blueray_twitter_callback', 'blueray_theme_social_options_page', 'social_settings_section' ); add_settings_field( 'facebook', 'Facebook', 'blueray_facebook_callback', 'blueray_theme_social_options_page', 'social_settings_section' ); add_settings_field( 'googleplus', 'Google+', 'blueray_googleplus_callback', 'blueray_theme_social_options_page', 'social_settings_section' ); register_setting( 'blueray_theme_social_options_page', 'blueray_theme_social_options_page', 'blueray_theme_sanitize_social_options_page' ); } // end sandbox_theme_intialize_social_options add_action( 'admin_init', 'blueray_theme_intialize_social_options' ); function blueray_social_options_callback() { echo '<p>Provide the URL to the social networks you\'d like to display.</p>'; } // end blueray_social_options_callback function blueray_twitter_callback() { // First, we read the social options collection $options = get_option( 'blueray_theme_social_options_page' ); // Next, we need to make sure the element is defined in the options. If not, we'll set an empty string. $url = ''; if( isset( $options['twitter'] ) ) { $url = $options['twitter']; } // end if // Render the output echo '<input type="text" id="twitter" name="blueray_theme_social_options_page[twitter]" value="' . $options['twitter'] . '" />'; } // end blueray_twitter_callback function blueray_facebook_callback() { $options = get_option( 'blueray_theme_social_options_page' ); $url = ''; if( isset( $options['facebook'] ) ) { $url = $options['facebook']; } // end if // Render the output echo '<input type="text" id="facebook" name="blueray_theme_social_options_page[facebook]" value="' . $options['facebook'] . '" />'; } // end blueray_facebook_callback function blueray_googleplus_callback() { $options = get_option( 'blueray_theme_social_options_page' ); $url = ''; if( isset( $options['googleplus'] ) ) { $url = $options['googleplus']; } // end if // Render the output echo '<input type="text" id="googleplus" name="blueray_theme_social_options_page[googleplus]" value="' . $options['googleplus'] . '" />'; } // end sandbox_googleplus_callback function blueray_theme_sanitize_social_options_page( $input ) { // Define the array for the updated options $output = array(); // Loop through each of the options sanitizing the data foreach( $input as $key => $val ) { if( isset ( $input[$key] ) ) { $output[$key] = esc_url_raw( strip_tags( stripslashes( $input[$key] ) ) ); } // end if } // end foreach // Return the new collection return apply_filters( 'blueray_theme_sanitize_social_options_page', $output, $input ); } // end blueray_theme_sanitize_social_options_page I have the following 1. php page that stores sessions. press submit and... 2. ...goes to perl/cgi page to interface with an api only available in perl, then auto redirects via HTTP headers to... 3. ... a php page where depending on the result a field is added to database then emailed, etc... then... 4.... redirects to main page so really all the user sees is page 1 -> hits submit -> ends up on page 4 via redirects Is there a problem with using redirects? Could the user intervene and prevent these redirects? Thanks I'm having a problem and need an answer to why its happening and how to prevent it. Scenario: I begin load my home page which starts with a session_start(); .... Before it FULLY completes loading I try to navigate to another page and BOOM, that page will not load and any other page that begins with session_start(); will not load unless I close and restart the entire browser or wait about 10 minutes.... I will note my website makes ajax calls every 5 seconds or so, but I use setTimeout for them. Any help??? Thanks ahead! Code: [Select] header('Location: ' . $register_success); Code: [Select] $register_success = 'register_success.php'; The header function above gets executed after a successful registering, and the variable is stated in the path.php file, which gets included into the header.php file, which also is included into the page, and also into the page with the register form. The register form is contained in the path model/register/register_script.php, and the file register_success.php is in the same folder. The problem I am having is that the header function does redirect to controller/register/register_success.php this used to be the previous location of that file. I am wondering is the old path saved somewhere in the cache, and this all is actually a caching problem? It does not seem to be a caching problem of the internet browser because I cleaned the cache out. What else could be the cause for this problem? If it is a caching problem, which cache could be, as in in which location? I am trying to create a script that alters the navigation div depending on the page the user is on. How do I get the current page using PHP? Quesion: Show each movie in the database on its own page, and give the user links in a "page 1, Page 2, Page 3" - type navigation system. Hint: Use LIMIT to control which movie is on which page. I have provided 3 files: 1st: configure DB, 2nd: insert data, 3rd: my code for the question. I would appreciate the help. I am a noob by the way. First set up everything for DB: <?php //connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //create the main database if it doesn't already exist $query = 'CREATE DATABASE IF NOT EXISTS moviesite'; mysql_query($query, $db) or die(mysql_error($db)); //make sure our recently created database is the active one mysql_select_db('moviesite', $db) or die(mysql_error($db)); //create the movie table $query = 'CREATE TABLE movie ( movie_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, movie_name VARCHAR(255) NOT NULL, movie_type TINYINT NOT NULL DEFAULT 0, movie_year SMALLINT UNSIGNED NOT NULL DEFAULT 0, movie_leadactor INTEGER UNSIGNED NOT NULL DEFAULT 0, movie_director INTEGER UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (movie_id), KEY movie_type (movie_type, movie_year) ) ENGINE=MyISAM'; mysql_query($query, $db) or die (mysql_error($db)); //create the movietype table $query = 'CREATE TABLE movietype ( movietype_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, movietype_label VARCHAR(100) NOT NULL, PRIMARY KEY (movietype_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); //create the people table $query = 'CREATE TABLE people ( people_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, people_fullname VARCHAR(255) NOT NULL, people_isactor TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, people_isdirector TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (people_id) ) ENGINE=MyISAM'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Movie database successfully created!'; ?> ******************************************************************** *********************************************************************** second file to load info into DB: <?php // connect to MySQL $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); //make sure you're using the correct database mysql_select_db('moviesite', $db) or die(mysql_error($db)); // insert data into the movie table $query = 'INSERT INTO movie (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director) VALUES (1, "Bruce Almighty", 5, 2003, 1, 2), (2, "Office Space", 5, 1999, 5, 6), (3, "Grand Canyon", 2, 1991, 4, 3)'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the movietype table $query = 'INSERT INTO movietype (movietype_id, movietype_label) VALUES (1,"Sci Fi"), (2, "Drama"), (3, "Adventure"), (4, "War"), (5, "Comedy"), (6, "Horror"), (7, "Action"), (8, "Kids")'; mysql_query($query, $db) or die(mysql_error($db)); // insert data into the people table $query = 'INSERT INTO people (people_id, people_fullname, people_isactor, people_isdirector) VALUES (1, "Jim Carrey", 1, 0), (2, "Tom Shadyac", 0, 1), (3, "Lawrence Kasdan", 0, 1), (4, "Kevin Kline", 1, 0), (5, "Ron Livingston", 1, 0), (6, "Mike Judge", 0, 1)'; mysql_query($query, $db) or die(mysql_error($db)); echo 'Data inserted successfully!'; ?> ************************************************************** **************************************************************** MY CODE FOR THE QUESTION: <?php $db = mysql_connect('localhost', 'root', '000') or die ('Unable to connect. Check your connection parameters.'); mysql_select_db('moviesite', $db) or die(mysql_error($db)); //get our starting point for the query from the URL if (isset($_GET['offset'])) { $offset = $_GET['offset']; } else { $offset = 0; } //get the movie $query = 'SELECT movie_name, movie_year FROM movie ORDER BY movie_name LIMIT ' . $offset . ' , 1'; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); ?> <html> <head> <title><?php echo $row['movie_name']; ?></title> </head> <body> <table border = "1"> <tr> <th>Movie Name</th> <th>Year</th> </tr><tr> <td><?php echo $row['movie_name']; ?></td> <td><?php echo $row['movie_year']; ?></td> </tr> </table> <p> <a href="page.php?offset=0">Page 1</a>, <a href="page.php?offset=1">Page 2</a>, <a href="page.php?offset=2">Page 3</a> </p> </body> </html> Hello frnds, Im new in ur forum....I want to know that my one page is taking too much time to load....in that page no images exists..but on that page around 6000 records are loding from database....I m confuse that may be such a large records it is taking too much time...so will u help me out that what can i do so the page can be loaded quickly with these records.... this is urgent for me.....pls pls pls....give me solution soon Thnx a lot in advance I have a page that processes a variable passed in the url to go get information out of a text file in JSON format. For some reason though, passing one variable loads a page, passing a certain variable (who's data in the file is virtually identical to the first) will cause the browser to just load the page indefinitely. Maybe even more strange is that on my local machine, the variable that won't load is switched, and the other loads fine. How can I debug what's happening when the page never loads so that I never get an error? Hey, I need to generate a script which tells me how long it takes for an external page to load... Please can you help? Thanks hello, i want to get into a particular page if the user stays more than lets say 20 minutes to automatically load another php page. More specific i have a page which is a test. The user answears to some multiple choice questions. i want him to have only a particular time to anwear. Lets say after 20 min i want to load the results page. Any ideas? Hi! I am looking for a script that counts how many queries is executed on page load? I hadn't realised one of my scripts was doing hundreds of queries simultaneously and never would of thought this would be the cause of high load. As I'm developing stuff in PHP, I want to ensure minimum queries are executed especially because I am doing this in a procedural manner and not OOP. Thanks in advance. Hi, I've been wondering if it is possible to load a php page according to certain time. For example at 12:00 pm a php form will pop up automatically informing an employee to fill in something in the form, another form will pop up at 4:00 pm, etc... Thanks in advance When a person visits my site I would like for the form on the page to submit and reload with the predetermined search criteria. Is this possible? So for example...if you visited my site as soon as you entered the from would submit and display Google search results for "php freaks" I tried header("location: mysite.com?q=php+freaks"); but that is a continuous loop. -Any thoughts I was wondering if it's possible to retain loaded files and the current error setttings after a
header("Location: xxxx.php")is issued, for example in this: // Start up the session - not used yet but there just in case session_start(1); // Enable the Autoloader and initialise it require_once 'Autoloader.php'; Autoloader::init(); // Check if the application has been installed yet ---------------------------- if(!file_exists('Engine/config.php')){ session_write_close(); header("Location: install/index.php"); die(); }And I get a class not found error when I open the install/index.php session_start(1); // @todo: Disable this in the production version .... I already did this in the main index -- do I have to do this on all pages that may error? error_reporting(E_ALL & ~E_STRICT); ini_set("display_errors",1); // Because we jumped here, we have to reinstall the autoloader -- why? require_once '../Autoloader.php'; Autoloader::init();While I can understand I wouldn't want this if I was firing off to a completely different site, is there anyway to retain the settings within the same server environment or do I have to reset everything as above. I even tried using session in the hope that this would 'remember' but it didn't work. Hi,
I am trying to make a page where the footer is loaded according to the screen size, so if someone is accessing the website via a tablet will be a footer, if it is from the computer, there will be another footer.
my problem is that although it is recognizing the windows width, it is not changing the footer accordingly.
this is my code:
$width = "<script>document.write(window.innerWidth);</script>"; if ($width < 900) { include("footer_mobile.php"); } else { include("footer.php"); }for some reason it is always loading the else footer even though the windows with changes. I added echo"$width" ; and the result of the variable was fine. does anyone know what the problem is cause it is driving me crazy? Is there some way of a php include which is visible on every page (footer), itself having two php includes, but only one of which would be visible, then on the user refreshing the page or on visiting another page on the site, that include would be replaced with another php include? Preferably done without any js. Any help appreciated. Chris can someone please help me with this I'm trying to make it so that when the page loads just the condition below will happend unless the if statment happends. so I need two if statments that work off of one condition? so i was thinking of using OR but i would need a if statement that says the page is being loaded what this code does it displays someones profile when search is hit but i want it to display the persons own profile soon as the page is loaded first Code: [Select] <?php if(isset($_POST['search'])) { // searches goaulds then displays them $search3 = "SELECT goauld,id FROM users WHERE goauld='".mysql_real_escape_string($_POST['goaulds'])."'"; $search2 = mysql_query($search3) or die(mysql_error()); WHILE($search1 = mysql_fetch_array($search2)){ $grab_goauld = $search1['goauld']; echo '<table width="300" height="5" border="1" align="center">'; echo '<th><center>Goauld Statistics</center></th>'; echo "<tr><td height='340'>$grab_goauld</td></tr>"; } } echo '</table>'; ?> I'm trying to block access to a particular page if the visitor is not from a specific country (using Maxmind Geoip Country database), but not quite sure how to code this properly: I tried this and many variations of this inside the head tags, bud doesn't work. Any suggestions on the best way to go about this? Code: [Select] <?php require_once("geoip.inc"); $gi = geoip_open("/home/username/GeoIP.dat",GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); if($country_code !== 'US') header("HTTP/1.0 404 Not Found"); exit; ?> |