SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    iframe for action

    Greetings! I used iframe to show errors from my login form, now user input is valid I want to direct the user to other page right after the form is submitted. Is it possible? thank you in advance.

  2. #2
    SitePoint Evangelist
    Join Date
    Apr 2009
    Location
    South Carolina
    Posts
    458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand you correctly, once they have logged in, you want to direct them to a new page. With my log-in, I use:
    PHP Code:
    header("Location: http://www.example.com/newpage.php"); 
    I have an if statement that checks to see if the user needs to change the password (using a temporary password). If they need a password change, I direct them to the change password page, otherwise, I send them to the logged in home page.
    Each day is a learning experience.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the above is mostly correct but you need to account for the base url if it ever changes the above code will fail.

    try something more along the lines of this.
    PHP Code:
     header('Location:'.$_SERVER['SERVER_NAME'].'/yourpage.php'); 
    coming soon sitejuju.com my new development portfolio

  4. #4
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    like

    if (username is true && password is true )
    {
    echo 'welcome user';
    header('Location:'.$_SERVER['SERVER_NAME'].'/yourpage.php');

    }
    else {
    echo 'invalid pass';
    }

    am i doing right?

  5. #5
    SitePoint Enthusiast jakub_polak's Avatar
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because you want to display the message after redirecting, then you should use it like this:

    PHP Code:
    header('Location:'.$_SERVER['SERVER_NAME'].'/yourpage.php'); 
    echo 
    'welcome user'
    If you use it like the code below, then PHP will display "Warning: Headers already sent".

    PHP Code:
    echo 'welcome user';
    header('Location:'.$_SERVER['SERVER_NAME'].'/yourpage.php'); 

  6. #6
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    thank you for the responses.

    I tried all the suggestions, the result brings me to the desired page but it shows on my iframe, what I want is to create new window when user submitted the right input..I used iframe to show my errors in validation.

  7. #7
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    php is not capable of open new windows that is where javascript would have to come in and play.
    coming soon sitejuju.com my new development portfolio

  8. #8
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    i tried javascript,and it works.. such that I'm having hesitation when to use and not to use javascript..just in case javascript console of my users is turned off they will not able to login in my application.am I right? perhaps I'm torn between the two..I keep on thinking not to use javascript since it works only for enhancing design..I'm a self taught programmer and I'm having trouble on that matter.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •