Link to home
Start Free TrialLog in
Avatar of Robert Thomas
Robert ThomasFlag for United States of America

asked on

Problems redirecting to index page after logining

I have created an login field were it is suppose to redirect users to either back to the home page or a registration page. The site is currently a subdomain on a yahoo site used for testing.  The problem is that when it redirects after the initail login it always point to the folder on the server instead of the actual subdomain address. For instance the main location is www.prism.dragteck.com, so when i login it should go to either the www.prism.dragteck.com address or www.prism.dragteck.com/index.php.  unfortuantly no matter what it always goes to http://www.prism.dragteck.com/prismV2/index.php. Pointing to the folder were it is stored on the sever.  I have everything I could to fix it.  On the test server on my local computer it works fine. Im wondering if it has something to do with yahoo's setup and if so what can I do to fix it.
Avatar of Joe Wu
Joe Wu
Flag of Australia image

how are you redirecting after a successful login?
Something like this would have worked (provided you are in directory http://www.prism.dragteck.com/prismV2/):

header("Location: ../index.php");

Let me know how you get on.
Avatar of Robert Thomas

ASKER

Im using the sever behaviors built into dreamweavers for the login function.  The directory folder location is actually dragteck.com/prismV2.  But I have it set up as a subdirectory on yahoo.  
It looks like the main problem is coming from the form submit button.  It is the only thing that is pointing to the directory.
Im not exactly sure how to fix this, since dreamweaver created the code.
Are you able to post the code?
not realy cause its a dreamweaver generated code and its not all in one place. I was wondering if there something maybe in the settings that i might need to change to fix this or if there are any special instructions for dealing with yahoo subdirecories
no i dont' think so, I have not ever had to use dm's generated code since I wrote my own login codes, however i think there is something in the code which references to the directory instead of the root. If you look through the code you should be able to find it?
I think this is the entire code but I don't see anything calling to that specific directory:

<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "level";
  $MM_redirectLoginSuccess = "index.php";
  $MM_redirectLoginFailed = "registration.php";
  $MM_redirecttoReferrer = true;
  mysql_select_db($database_prism, $prism);
        
  $LoginRS__query=sprintf("SELECT user, password, level FROM user WHERE user='%s' AND password='%s'",
  get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
   
  $LoginRS = mysql_query($LoginRS__query, $prism) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
   
    $loginStrGroup  = mysql_result($LoginRS,0,'level');
   
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;           

    if (isset($_SESSION['PrevUrl']) && true) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];      
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
>>$_SESSION['PrevUrl'] = $_GET['accesscheck'];

where is $_GET['accesscheck'] coming from? check its value.
ASKER CERTIFIED SOLUTION
Avatar of Joe Wu
Joe Wu
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial