Reputation: 13
I'm working on a project.
So here is the problem if I my insert query is a success i want to echo "SUCCESSFUL MESSAGE IN ANOTHER PAGE" something like this below
if($class->insertreg($a,$b){
echo header(location:successful.php);
echo $a ; //this is the username
echo $b; // this is the email address
}
Upvotes: 1
Views: 266
Reputation: 14544
if ($class->insertreg($a, $b) {
$_SESSION['user'] = [
'username' => $a,
'email' => $b
];
header('Location: successful.php');
}
And on your successful.php you access the values in the session:
<?php echo $_SESSION['user']['username'] . ' | ' . $_SESSION['user']['email']; ?>
Upvotes: 1
Reputation: 6732
if($class->insertreg($a,$b){
header("location:successful.php?a=$a&b=$b");
}
However, a
and b
are bad names for a variable.
You can access the two variables in the successful.php
with reading from GET
if(isset($_GET['a']) && isset($_GET['b']))
{
echo "<div>A: $a, B: $b</div>"
}
Upvotes: 0