How to Output Messages from PHP page to another?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • olddocks
    New Member
    • Nov 2007
    • 26

    How to Output Messages from PHP page to another?

    what is the best way to output error messages from one page to another?

    i currently send the messages to display using header() with GET

    [PHP]header("Locatio n: /file.php?msg=In valid Login)[/PHP]
    Is there any good workarounds? or a standard way of doing it?
  • stepterr
    New Member
    • Nov 2007
    • 157

    #2
    Originally posted by olddocks
    what is the best way to output error messages from one page to another?

    i currently send the messages to display using header() with GET



    Is there any good workarounds? or a standard way of doing it?

    I've done it two different ways.
    on the first page that produces the error I will do something along the lines of
    [PHP]

    if(//whatever produces your error)
    {
    print "Invalid Input";
    include 'file.php';
    }[/PHP]

    OR

    the other way would be to do something like this on the first page.
    [PHP]// assign it to a variable like
    $errormsg ="Invalid Input";
    // add it to a hidden variable
    print "<input type='hidden' value=$errormsg name='message'>
    [/PHP]

    then on the second page
    [PHP]$errormsg = $_POST['message']; //to get the value from the posted page
    print $errormsg; //to print the message[/PHP]

    Comment

    • underscore
      New Member
      • Jul 2007
      • 30

      #3
      to output the message to the other page try to look the $_REQUEST

      Comment

      Working...