I am doing HTML with PHP and MySql. After some database operation that was performed by the user, my system redirects the user to the original database page in order to show him the updated table. (I am done with this part). At the same time, I wish to display a message to the user on the original page (the one where the system moved) to notify him with the success of the operation. How can I possibly display this message?
Here's my php code that moves to the other page.
Header( 'Location: Database.php');
Header( 'Location: Database.php?success=1' );
And in the Database.php page :
if ( isset($_GET['success']) && $_GET['success'] == 1 )
{
// treat the succes case ex:
echo "Success";
}
Store it in the session
as sort of a "flash"-message:
$_SESSION['message'] = 'success';
and show it in Database.php
after the redirect. Also delete its content after displaying it:
print $_SESSION['message'];
$_SESSION['message'] = null;
The advantage of this is, that the message won't be shown again every time the user refreshes the page.
you can do this:
$_SESSION['msg']="Updation successfully completed";
header("location:database.php");
on database.php
echo $_SESSION['msg'];
unset($_SESSION['msg']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With