0

I have an index.php for registration, a login.php as the registration handler. when the registration is failed, it sent out the error message to client. I use this code for sending out the message

header('Location: http://localhost/musicshare/index.php?reg=false');

and receive in index.php

if(isset($_POST['reg'])){
        echo 'set';//for checking whether reg is set
        if($_POST['reg']=='false'){
            echo '<script type="text/javascript">';
            echo 'alert("Reg faile")';
            echo '</script>';
        }
    }

However, It seems not working at all; Please help, thanks.

1
  • If your question is answered accept your suitable answer. Commented Jun 15, 2012 at 6:21

2 Answers 2

1

Use $_GET instead of $_POST:

if (isset($_GET['reg']) && $_GET['reg'] == 'false'){
   // do something
}
Sign up to request clarification or add additional context in comments.

Comments

0

When you use a header() it fires a GET request.

So you should use $_GET['reg']

if(isset($_GET['reg'])){
    echo 'set';//for checking whether reg is set
    if($_GET['reg']=='false'){
        echo '<script type="text/javascript">';
        echo 'alert("Reg faile")';
        echo '</script>';
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.