SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: PHP Redirects?

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Redirects?

    Hi Everyone,

    I have a question regarding php redirects. If you visit the below URL and if your not logged in - your presented with a statement saying you have to be logged in (which is what I want) but after the person clicks on "Click Here" they are taken to the login page where they can login. My question is, how would I redirect visitors back to the car-search page they originally wanted to visit?

    http://whatsmyowncarworth.com/class-...car-search.php

    This is my php session syntax on the car-search.php page.

    PHP Code:
    <?php
    session_start
    ();

    if (!isset(
    $_SESSION['myusername'])) {
    echo 
    "Hello, you must have an account to view this page. <a href=\"http://whatsmyowncarworth.com/class-work/sign2/main_login.php\">Click Here</a>!<br>";
    exit();
    }
    ?>

  2. #2
    SitePoint Zealot
    Join Date
    Feb 2005
    Location
    Aveiro, Portugal
    Posts
    165
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Just save the current url in a session variable on each page.
    After the login, redirect to that url.

    HTH
    Yours truely
    Mário Ramos


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
  •