Im making a php game and I encountered this problem, I want so whenever someone levels up and clicks on what stat he wants to increase (Strength in this case), the menu shows his new stats instead of old ones.
I wrote my code below, I simplified it and removed all the unnessesary crap so its easier to read.
This is my level up form.
function lvl_up(){
global $login_id;
$lvlup_text=
"You leveled UP ! Please choose what stats you want to increase.
<form name=cetcom method=POST action=game.php?loc=attack>
<input class='button' type='submit' name=up_str value='Add STR'>";
if (isset($_POST['up_str'])){
echo "<br>";
dbn("UPDATE user_info SET str = str+'70' WHERE login_id = '$login_id'");
dbn("UPDATE user_info SET level = level+'1' WHERE login_id = '$login_id'");
dbn("UPDATE user_info SET str = str+'20' WHERE login_id = '$login_id'");
$info = get_info($login_id);
$lvlup_text="Done.";
}
This is my menu code, its what I want to refresh.
function print_menu() {
global $login_id;
$info = get_info($login_id);
echo
"Level=".$info['level']."<br>.
"Str=".$info['exp']."<br>;
}
My code (simplified)
print_menu();
lvl_up();
Now suppose I have 50 str, and I lvled up and clicked on 'Add STR', then it showed message 'Done' confirming thats stats were added succesfully. What my problem is that I have to refresh the page in order to see my new stats on the menu.
Please help me 😕 😕