Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda