Please I created a form with an action page. That retrieves a value from MySQL database column.
The form submits quite alright and the data is retrieved, too. But the problem is the header('Location: home.php'); has refused to redirect the user back home after the information has been retrieved. Plus, the user needs to refresh the browser before they see the retrieved data so I don't know it is possible to do the following:
By the way, this is the PHP action page:
<?php
session_start();
include(cafedbconfig.php);
$cafeconnection = mysqli_connect('localhost', 'dbuser', 'dbpass', 'dbname');
$query = "SELECT name, email, password, balance FROM cafeusers WHERE username = '".$_SESSION['username']."'";
$result = mysqli_query($cafeconnection, $query) or die (mysqli_error($MyConn));
if ($row = mysqli_fetch_assoc($result)){
$balance = (int) stripslashes($row["balance"]);
$email = $row["email"];
$name = $row["username"];
$cafepass = $row["password"];
}
mysqli_free_result($result);
if(isset($_POST['cafepass'])){
$pass = $_POST['cafepass'];
$newbalance1 = $balance - 50;
$select = "UPDATE cafeusers SET balance = '$newbalance1' WHERE username='$name' AND password='$pass'";
}
if (mysqli_query($cafeconnection, $select)) {
$returnvalue = "VIP 1 Upgraded successfully!";
} else {
$returnvalue = "Error" . mysqli_error($cafeconnection);
}
mysqli_close($cafeconnection);
return $returnvalue;
header ('Location: home.php');
?>
I want to redirect to home.php after this action has been executed and then return with $returnvalue back to home.php because I intend to use the said variable.
if possible, force a browser refresh after doing so. I'd really appreciate the help. Cheers.