[SOLVED] Getting a completely unexpected redirect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vaughtg
Forum Commoner
Posts: 39
Joined: Thu Feb 17, 2011 9:43 am

[SOLVED] Getting a completely unexpected redirect

Post by vaughtg »

I have the following code at the top of a page:

Code: Select all

<?php
  require_once '../classes/Applicant.php';
  $applicant = new Applicant();
  if(isset($_POST['updateProfile'])){
    if("yes" == $_POST['updateProfile']){
      $applicant->saveEdits();
    }elseif ("new" == $_POST['updateProfile']){
      $applicant->createProfile();
    }
  }
  if(!isset($_SESSION['user'])){
    $_SESSION['srcPage'] = "profile";
    //header('Location: main.php?page=login');
  }
  require '../classes/Input.php';
  $inpt = new Input();
?>
The purpose of this is to check and see if the profile is being updated OR created.
If it's being updated, then the currently logged in user has their profile updated with the POSTed data.
If it's being created, then the database record is created AND the user is AUTHENTICATED.
In either case, $_SESSION['user'] is set by the time the script gets to the check for authentication.

All of that is explanation of intended functionality. What's really happening is the first line (require_once '../classes/Applicant.php';) is hit and the page redirects (even with the redirect on THIS page commented out) as if the authentication check has occurred and failed.
My initial thought was that Applicant::_construct had some authentication check that was failing - but it's empty.
Next I thought it might be my IDE - but browser functionality echoes the exact same behavior.

So, now I'm at a complete loss as to what this could be.
Any constructive suggestions will be greatly appreciated.

Regards,
- G
Last edited by vaughtg on Sat Apr 16, 2011 10:31 am, edited 1 time in total.
vaughtg
Forum Commoner
Posts: 39
Joined: Thu Feb 17, 2011 9:43 am

Re: Getting a completely unexpected redirect

Post by vaughtg »

Okay, issue resolved. Serious case of DA in not paying attention to my file names. Or not paying attention to my pathing (still gotta work that detail out).

I have a class file in /classes/Application.php and /web/application.php and somewhere in the chain a require_once 'Application.php'; redirects to /web/application.php rather than /classes/Application.php - soooo, replacing that require_once 'Application.php'; with require_once '../classes/Application.php'; and moving on.
Post Reply