On authentication, how to redirect to one of 20 websites?
Posted: Sat Jan 09, 2010 2:10 pm
I have over 20 web sites. They all use a central members database. Upon registration and/or login, I want the user to go the appropriate site, based on one of the fields in the database (state). Because they are all using the same dB for authentication, they would be able to log in from any of the sites and go to their specific site.
Right now it sort of works, but they all go to the same site because of the way it is set up and I can't quite get my head around how to make it do what I want.
Here is what I have now.
Upon authentication (uname and pword), $loginsuccess="a specific site" -- this works
I want it to be:
Upon authentication, $loginsuccess="one of the 20 sites, but the one that is specific to their state as indicated in the dB"
HERE IS THE CODE:
setcookie ("USERNAME", $_POST['username'],0,'/');
setcookie ("PASSWORD", $_POST['password'],0,'/');
include_once ("auth.php");
include_once ("authconfig.php");
$username = $_POST['username'];
$password = $_POST['password'];
$Auth = new auth();
$detail = $Auth->authenticate($username, $password);
if ($detail==0)
{
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $stateloginfailure; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
elseif ($detail['team'] == "Admin") {
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $admin; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
elseif ($detail['team'] == "Admin") {
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $success; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
else
{
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $loginsuccess; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
?>
___________-
$loginsuccess is in the authconfig.php file, where my connection to the dB is also. (Auth.php, authconfig.php, and my actual authenticationcheck.php files are already included.)
This works, but isn't what I want.
$loginsuccess = "http://127.0.0.1/somesite/home.html"; // PAGE SHOWN IF USER IS AUTHENTICATED
I would like it to ge:
$loginsuccess="one of the 20 sites, but the one that is specific to their state as indicated in the dB"
for example:
If state=Alabama, GoTo site1
elseif state=Minnesota, GoTo site2
elseif state=New York, site3
etc.
---------------
What, if anyone can help, should I actually be coding?
Thanks in advance.
Right now it sort of works, but they all go to the same site because of the way it is set up and I can't quite get my head around how to make it do what I want.
Here is what I have now.
Upon authentication (uname and pword), $loginsuccess="a specific site" -- this works
I want it to be:
Upon authentication, $loginsuccess="one of the 20 sites, but the one that is specific to their state as indicated in the dB"
HERE IS THE CODE:
setcookie ("USERNAME", $_POST['username'],0,'/');
setcookie ("PASSWORD", $_POST['password'],0,'/');
include_once ("auth.php");
include_once ("authconfig.php");
$username = $_POST['username'];
$password = $_POST['password'];
$Auth = new auth();
$detail = $Auth->authenticate($username, $password);
if ($detail==0)
{
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $stateloginfailure; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
elseif ($detail['team'] == "Admin") {
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $admin; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
elseif ($detail['team'] == "Admin") {
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $success; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
else
{
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $loginsuccess; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
?>
___________-
$loginsuccess is in the authconfig.php file, where my connection to the dB is also. (Auth.php, authconfig.php, and my actual authenticationcheck.php files are already included.)
This works, but isn't what I want.
$loginsuccess = "http://127.0.0.1/somesite/home.html"; // PAGE SHOWN IF USER IS AUTHENTICATED
I would like it to ge:
$loginsuccess="one of the 20 sites, but the one that is specific to their state as indicated in the dB"
for example:
If state=Alabama, GoTo site1
elseif state=Minnesota, GoTo site2
elseif state=New York, site3
etc.
---------------
What, if anyone can help, should I actually be coding?
Thanks in advance.