hi guys i need help how can i redirect session to usercp.php and admincp.php
i try all but i got failed any can help me on this
( this my Login code: )
<?php
session_start();
include('info.php');
$UserID = ms_escape_string($_POST['UserID']);
$Pw = ms_escape_string($_POST['Pw']);
$Error=0;
$res=odbc_exec($conn,"SELECT * FROM PS_UserData.dbo.Users_Master U
INNER JOIN PS_GameData.dbo.Chars UM ON UM.UserUID=U.UserUID
WHERE um.UserID COLLATE DATABASE_DEFAULT = '{$UserID}'
AND u.Pw COLLATE DATABASE_DEFAULT = '{$Pw}'");
$row=odbc_num_rows($res);
if ($row == 0) {
$Error++;}
if ($Error != 0){die ('You cannot login without one character');}
else{
$_SESSION['UserID']=$UserID;
$_SESSION['user']=true;
$_SESSION['session_id']=createSession($UserID);
header('Location: usercp.php');
}else{
$_SESSION['UserID']=$UserID;
$_SESSION['admin']=true;
$_SESSION['session_id']=createSession($UserID);
header('Location: admincp.php');
}
?>
( this is my Info.php code )
<?php
//Custom functions
function ms_escape_string($data) {
if ( !isset($data) or empty($data) ) return '';
if ( is_numeric($data) ) return $data;
$non_displayables = array(
'/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
'/%1[0-9a-f]/', // url encoded 16-31
'/[\x00-\x08]/', // 00-08
'/\x0b/', // 11
'/\x0c/', // 12
'/[\x0e-\x1f]/' // 14-31
);
foreach ( $non_displayables as $regex )
$data = preg_replace( $regex, '', $data );
$data = str_replace("'", "''", $data );
return $data;
}
function unsetSession ($SessionVariable) {
unset($GLOBALS['_SESSION'][$SessionVariable]);
}
function createSession ($UserID){
$md5 = md5($_SERVER['REMOTE_ADDR'].$UserID.$_SERVER['HTTP_USER_AGENT']);
return $md5;
}
function checkSession ($Session,$UserID){
$md5 = md5($_SERVER['REMOTE_ADDR'].$UserID.$_SERVER['HTTP_USER_AGENT']);
if($Session != $md5){
unsetSession('UserID');
unsetSession('session_id');
exit(header("location:index.php"));
}else
{
return true;
}
}
function checkEmail ($email) {
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
return false;
}
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if
(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
?'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
$local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false;
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if
(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
?([A-Za-z0-9]+))$",
$domain_array[$i])) {
return false;
}
}
}
return true;
}
function checkUser ($Char,$User,$conn) {
$Check = odbc_exec($conn,"SELECT UserID FROM PS_GameData.dbo.Chars WHERE CharID='".$Char."'");
$User2 = odbc_result($Check,'UserID');
if(odbc_num_rows($Check) != 1){return false;}
if($User != $User2){return false;}
return true;
}
?>
( In my usercp,php code session )
<?php
error_reporting(E_ALL);
//Setting informaton
include('info.php');
session_start();
if (!isset($_SESSION['session_id'])){header("location:index.php");}
checkSession($_SESSION['session_id'],$_SESSION['UserID']);
?>
( In my admincp,php code session )
<?php
error_reporting(E_ALL);
//Setting informaton
include('info.php');
session_start();
if (!isset($_SESSION['session_id'])){header("location:index.php");}
checkSession($_SESSION['session_id'],$_SESSION['UserID']);
?>