Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 88739

Redirect to diffrent urls depending on entry in database.

$
0
0

I have a login page that I want to redirect to the user based on the value in my 'Auth' category of my mysql database.  I am trying to figure out how to get the login to redirect if it sees "IL" in the 'Auth' that it goes to indexil.php, "IA" goes to indexia.php and I also have FL and NV to redirect to their corresponding pages.  Hoping someone can help me on this.  Below is the code that Dreamweaver created.

 

Login Page

 

<?php require_once('../Connections/Users.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

?>

 

<?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 = "";

  $MM_redirectLoginSuccess = "../members/";

  $MM_redirectLoginFailed = "login.php";

  $MM_redirecttoReferrer = false;

  mysql_select_db($database_Users, $Users);

 

  $LoginRS__query=sprintf("SELECT Uname, Pword FROM users WHERE Uname=%s AND Pword=%s",

    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

  

  $LoginRS = mysql_query($LoginRS__query, $Users) or die(mysql_error());

  $loginFoundUser = mysql_num_rows($LoginRS);

  if ($loginFoundUser) {

     $loginStrGroup = "";

   

    //declare two session variables and assign them

    $_SESSION['MM_Username'] = $loginUsername;

    $_SESSION['MM_UserGroup'] = $loginStrGroup;         

 

    if (isset($_SESSION['PrevUrl']) && false) {

      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];   

    }

    header("Location: " . $MM_redirectLoginSuccess );

  }

  else {

    header("Location: ". $MM_redirectLoginFailed );

  }

}

?>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<?php include('inc_title.php') ?>

<link href="styles.css" rel="stylesheet" type="text/css">

</head>

 

<body><div id="banner"></div>

<div id="container">

    <div align="center">

      <p> </p>

      <p><span class="largebold">Forms Login</span></p>

      <form name="form1" method="POST" action="<?php echo $loginFormAction; ?>">

        <p>Username:

          <input name="username" type="text" id="username">

        </p>

        <p>Password:

          <input name="password" type="password" id="password">         

          </p>

        <p>

          <input type="submit" name="Submit" value="Login">

        </p>

      </form>

      <p>

        <!-- end right -->

          </p>

  </div>

 

 

    <div id="clear">        </div>

</div><!-- end container -->

 

</body>

</html>

 

 

index page

 

 

<?php include('inc_auth.php') ?>

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<?php include('inc_title.php') ?>

<link href="styles.css" rel="stylesheet" type="text/css">

</head>

 

<body><div id="banner"></div>

<div id="container">

    <div id="left">

<?php include('inc_formselector.php') ?>

    </div> <!-- end left -->

 

   

    <!-- end right -->

  <div id="clear">        </div>

</div><!-- end container -->

 

</body>

</html>

 

 

inc_auth  page


<?php

if (!isset($_SESSION)) {

  session_start();

}

$MM_authorizedUsers = "";

$MM_donotCheckaccess = "true";

 

// *** Restrict Access To Page: Grant or deny access to this page

function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {

  // For security, start by assuming the visitor is NOT authorized.

  $isValid = False;

 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.

  // Therefore, we know that a user is NOT logged in if that Session variable is blank.

  if (!empty($UserName)) {

    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.

    // Parse the strings into arrays.

    $arrUsers = Explode(",", $strUsers);

    $arrGroups = Explode(",", $strGroups);

    if (in_array($UserName, $arrUsers)) {

      $isValid = true;

    }

    // Or, you may restrict access to only certain users based on their username.

    if (in_array($UserGroup, $arrGroups)) {

      $isValid = true;

    }

    if (($strUsers == "") && true) {

      $isValid = true;

    }

  }

  return $isValid;

}

 

$MM_restrictGoTo = "login.php";

if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  

  $MM_qsChar = "?";

  $MM_referrer = $_SERVER['PHP_SELF'];

  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";

  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)

  $MM_referrer .= "?" . $QUERY_STRING;

  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);

  header("Location: ". $MM_restrictGoTo);

  exit;

}

?>

 

 

I hope this will help ya all in assisting me on this.  I have been working on this pne for a few weeks now.  I can only get one of the 4 redirects to work.   Thanks in advance


Viewing all articles
Browse latest Browse all 88739

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>