user2437988
user2437988

Reputation: 1

php success message handling

I've a form i slideDown with Jquery, and a php script in which i need to redirect after sendind data to server (php),and also showing a "success" message (not in the url but in the form).
I'm doing it this way (as i found here in stackoverflow):

header("location:VIP.php?response=1");

and and in VIP.php right after :

if (isset ($_GET['response']))
{
    if ($_GET['response']=="1")
    {
      echo "Se ha registrado con éxito"; //this is my success message (spanish)
    }
}

it works like a charm, the only thing is thay i need to style this, it shows at the top left of the body ... and i don't know how to make it show in the form (or any other specific div)

If anyone can enlight me, i'd much appreciate it.Thanks!

Upvotes: 0

Views: 623

Answers (1)

DAG
DAG

Reputation: 6994

Do it like this:

if (isset ($_GET['response']))
{
   if ($_GET['response']=="1")
   {
       $msg = "Se ha registrado con éxito"; //this is my success message (spanish)
   }
}

and then somewhere in your html page (e.g. in your form):

<?php if( $msg ): ?><div class="notice"><?php echo $msg ?></div><?php endif; ?>

Upvotes: 1

Related Questions