Submit button only updates the BD after pressing F5

Asked

Viewed 91 times

0

I am creating a browser RPG game where the player registers first and race and then is redirected to a page where he chooses the class. By clicking the Ubmit button, the race and race status are saved in the BD and the player should be redirected then the problem is that when I click to register the race, the page updates but the user data is not sent to the BD, only when I hit F5 is the data sent and I am redirected to the next page. Does anyone know why it happens?

    if ($numPers == 1) {
        header("location:cadastrarclasse.php");
    }elseif($numPers > 1){
        header("location:taverna.php");
    }
    else{

This code is above the head. The Else is in case the user has not registered anything yet, then it is on the page to register race.

  • Well friend you need to put an excerpt of the code where you think the problem is. So it gets hard to help.

  • My problem is just not knowing where is the error ashuuasuashuas. I put the part where the pages are redirected to help understand the logic.

  • In this case post a larger amount of lines.

1 answer

0

Header does not transfer $_POST or $_GET data between PHP pages, only sets the HTTP header and redirects the user. http://php.net/manual/en/function.header.php

You should use a include, that transfers the execution flow of your Script to another file and returns after it.

if ($numPers == 1) {
   include "cadastrarclasse.php";
} else if($numPers > 1) {
   include "taverna.php";
}

Similar problem you must be facing here:

https://stackoverflow.com/questions/4281900/php-header-redirect-with-post-variables

Browser other questions tagged

You are not signed in. Login or sign up in order to post.