How to pass error message in one page to another page

Discussion in 'PHP' started by nile1483, Jun 29, 2008.

  1. #1
    friends,

    i just make simple user registration and authorization program, where user can registration, update their profile etc.

    i just want to as you how to pass message something like

    1. when user registration (registration.php) first time page redirect to login(login.php) page i want to display message that "you are registration successfully, please login using your email and password"

    2. When user edit(edit.php) their profile he/she will redirect into their profile page(profile.php) message will display "Your Profile updated successfully"

    waiting for your reply
    Thanks
    nile
     
    nile1483, Jun 29, 2008 IP
  2. 2slick

    2slick Peon

    Messages:
    73
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use post or get variables and pass them to the other page.
     
    2slick, Jun 29, 2008 IP
  3. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #3
    Ok, it will be so simple. How do you redirect the page, using header function, or javascript ?

    regards
     
    Vooler, Jun 29, 2008 IP
  4. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    PHP:

    die ( header( 'Location: [the url]?[get vars]' ) );
     
    Danltn, Jun 29, 2008 IP
  5. nile1483

    nile1483 Active Member

    Messages:
    345
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #5
    I redirect using header

     
    nile1483, Jun 29, 2008 IP
  6. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #6
    Dan has already posted what I was to tell you. Besides here is exact code that you shall use.

    Now in your your_script.php

    
    if(isset($_GET['msg'])) {
        print htmlspecialchars($_GET['msg']); //print message
    }
    
    PHP:

    I hope it helps.
     
    Vooler, Jun 30, 2008 IP
  7. clarky_y2k3

    clarky_y2k3 Well-Known Member

    Messages:
    114
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    108
    #7
    As others have said you can use the query line aspect of the URL in order to pass information from one page to another. Sessions are also a viable way of accomplishing this.

    Personally I would not transfer the entire error message but rather a number pertaining to an error. You could use a switch statement or construct an array mapping numbers to their relevant messages to do this.
     
    clarky_y2k3, Jun 30, 2008 IP
  8. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #8
    it is better to use header() to redirect because if somebody hits back then it wont go back after registration.
    BTW if you want registration script, download free from www.php-login-script.com
     
    olddocks, Jun 30, 2008 IP