Jump to content

PHP file redirect?

DeagleMaster

I have a PHP file that has a button to updat the info in my database. Once the button is pressed it uses another PHP file to run the update in the database. I am trying to make it redirect me to a php file with a table containing the info in the database.

 

This is what I have now. It just displays text saying that the update was successful. I would like it to redirect me to the PHP file containing the table. I would like to avoid using URL redirects. 

    if($kobling->query($sql)) {
        echo "Update successful";
    }
   else {
         echo "Something went wrong $sql ($kobling->error).";
     }

Link to comment
Share on other sites

Link to post
Share on other sites

You could use the include_once function to include the php file in your active script.

Then, call a function from that file (which would check the uploaded stuff, and run the queries or whatever)

 

other tricks that could be done is to have some javascript on the page (dump it on the page) that makes a request after a second or so after page loads, retrieves the info you want shown on the screen and puts the info on the screen.

 

The header function only works if you're 100% sure there's no previous output to the user ... you could guarantee that sort of using ob_start / ob_clean (to reset the output buffer)

Link to comment
Share on other sites

Link to post
Share on other sites

30 minutes ago, mariushm said:

You could use the include_once function to include the php file in your active script.

Then, call a function from that file (which would check the uploaded stuff, and run the queries or whatever)

 

other tricks that could be done is to have some javascript on the page (dump it on the page) that makes a request after a second or so after page loads, retrieves the info you want shown on the screen and puts the info on the screen.

 

The header function only works if you're 100% sure there's no previous output to the user ... you could guarantee that sort of using ob_start / ob_clean (to reset the output buffer)

It didn't work in the if query. It didn't work outside the if query. It worked if I deleted the if query, but than the character doesn't update 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×