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.
Robert ThomasProgram Analyst / Web DeveloperAsked:
Who is Participating?
 
nizsmoConnect With a Mentor DeveloperCommented:
ahh this is the line you need to look at:

header("Location: " . $MM_redirectLoginSuccess );

now what exactly is $MM_redirectLoginSuccess? This must be your problem.

edit: found the problem:

$MM_redirectLoginSuccess = "index.php";

change the above line to:

$MM_redirectLoginSuccess = "../index.php";

And your problem should be solved.

Let me know how you go.
0
 
nizsmoDeveloperCommented:
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.
0
 
Robert ThomasProgram Analyst / Web DeveloperAuthor Commented:
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.  
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Robert ThomasProgram Analyst / Web DeveloperAuthor Commented:
It looks like the main problem is coming from the form submit button.  It is the only thing that is pointing to the directory.
0
 
Robert ThomasProgram Analyst / Web DeveloperAuthor Commented:
Im not exactly sure how to fix this, since dreamweaver created the code.
0
 
nizsmoDeveloperCommented:
Are you able to post the code?
0
 
Robert ThomasProgram Analyst / Web DeveloperAuthor Commented:
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
0
 
nizsmoDeveloperCommented:
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?
0
 
Robert ThomasProgram Analyst / Web DeveloperAuthor Commented:
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 );
  }
}
?>
0
 
CWS (haripriya)Commented:
>>$_SESSION['PrevUrl'] = $_GET['accesscheck'];

where is $_GET['accesscheck'] coming from? check its value.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.