Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
how to show alert in the redirected page?

in index.php I have 3 buttons (add, delete, edit)

if I click to delete it will redirect to the delete page query (delete.php)

after delete success, the page redirects to index.php and the sweet alert2 will popup with a success message (deleted successfully)

if I add a user the msg will change to added successfully

it depends on where I redirect to index.php

so what I can do?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

While redirecting from delete.php/edit.php to index.php you can pass some query params.

Redirection from delete.php will look like index.php?msg="deleted successfully";

Redirection from edit.php will look like index.php?msg="added successfully"

In index.php you can read the query string msg and display the alert box

Here is the refs to get query string param.

How can I get query string values in JavaScript?

about 4 years ago · Juan Pablo Isaza Report

0

Solution1

Before redirecting, you should create a session object and save the alert messages in sessions.

start_session()

$_SESSION["alert"] = ["type" => "success", "message" => "User deleted successfully"];

On index.php page

On a index.php page, check if there’s a flash/alert message. If so, output and delete it.

if (isset($_SESSION["alert"]))
{

echo 

"<div class='alert alert-success alert-dismissible'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <h4><i class='icon fa fa-check'></i> Alert!</h4>
                 $_SESSION["alert"]
              </div>";
  
unset($_SESSION["flash"]);
}

Thats it.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!