Jump to content

Referrer page.


timmy0320

Recommended Posts

Alright, I'm having a little issue here. I have a login system that registers through a process page. The process page checks for what form was submitted $_POST['login'], $_POST['register'], etc. or if it finds nothing it returns to the main page.

 

session.php

My session page declares the referrer variable in my sessionStart() function. Example:

      // set refer page for process
      if(isset($_SESSION['url'])){
         $this->referrer = $_SESSION['url'];
      } else {
         $this->referrer = "/";
      }

 

process.php

Once the process form checks for the appropriate one, in this case, login, then it calls to a function to which I have set. Example:

   // process login
   // if errors found client is redirected to fix information
   // if no errors, user is logged in
   function procLogin() {
      global $session, $function_form;
      // match info with user attempt to login
      $retval = $session->login($_POST['user'], $_POST['pass']);

      // login was successful
      if($retval) {
        // echo $session-referrer;
         header("Location: ".$session->referrer);
      }
      // login failed.
      else {
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $function_form->getErrorArray();
         // echo $session->referrer;
         header("Location: ".$session->referrer);
      }
   }

 

 

user.php

I have a user page uses switch and case which sets the URL and loads the appropriate form. Example:

    case 'login':

        $session->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
        include ("templ/user_login_body.php");
        echo "<br>";
        echo $_SESSION['url'];
    break;

 

 

 

Now, what I want to know is when it's setting the $_SESSION['url'] it's not grabbing any of the cases, instead of the referral being user.php?do=login it is just showing user.php. Therefore, it is not going back to the case to which I need it to (which would be the login case). Such as the user_login_body contains an (if $session->logged_in) statement that refers to the main user panel } else { it reports any errors. Is there a simple way of doing this? My guess is to change the code in each case that contains $session->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; to add on at the end of it the "?do=(case)" manually but there's got to be some type of way to do it without having to do that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.