Jump to content

[SOLVED] A way to call a function with out reloading using a hyperlink


underv3

Recommended Posts

Just to start I do know about the method to use a hyperlink but it does reload the page.

 

The reason why I need the page to not be reloaded is because it is a sort of query page that query's the database. It is dynamic, as in before you go to the query page you have to select (from a drop down menu) which topics you would like to display.

 

The query page then gets the post values. When you reload the page it gives the form resubmission error.

 

I'm going to take a guess and say there is a way to store those post value upon a reload, but I am not sure. If someone could help me out with this that would be great ;D

 

Thanks!

You could store the $_POST variables as $_SESSION variables on the first entry, and then stop using $_POST when refreshing. You'd put something like this at the top of your script:

 

session_start();

if ($_POST) {
    $_SESSION['blah'] = $_POST['blah'];
    $_SESSION['bleh'] = $_POST['bleh'];

    // "Refresh" the page without POSTage. Your $_POST variables are safely stored in $_SESSION
    header('Location: this_page.php');
    die;
}

$blah = $_SESSION['blah'];
$bleh = $_SESSION['bleh'];

// your script continues here...

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.