Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 25th, 2004, 03:40 PM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Redirecting logged on Users

Hi, I am trying to read in a testscore from the query ($LoginRS__query=sprintf) below, and use this to redirect the users after they log onto the site to the pages in the if/else statements.
I am trying to replace ($MM_redirectLoginSuccess = "modeselection.php";) line with the if/else statement. I do not know how to extract the testscore field from the query below and compare it to the values in the if/else statement.
Here is the code to date.
Can anyone help?

Fletch lives

<?php require_once('Connections/logininfo.php'); ?><?php
// *** Validate request to login to this site.
session_start();

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

if (isset($_POST['txtusername'])) {
  $loginUsername=$_POST['txtusername'];
  $password=$_POST['txtpassword'];
  $MM_fldUserAuthorization = "";

    if ($testscore <= 0.965)
        {
              $MM_redirectLoginSuccess = "r1j1txt.php";
        }
    elseif ($testscore >= 1.060)
        {
            $MM_redirectLoginSuccess = "r1j1img.php";
        }
    elseif ($testscore > 0.965 and $result < 1.060)
        {
        $MM_redirectLoginSuccess = "r1j1imgtxt.php";
        }


//$MM_redirectLoginSuccess = "modeselection.php";


  $MM_redirectLoginFailed = "errorlogin.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_logininfo, $logininfo);

  $LoginRS__query=sprintf("SELECT username, password, testscore FROM logininfo WHERE username='%s' AND password='%s'",
  get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

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

  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";

    //declare two session variables and assign them
    $GLOBALS['MM_Username'] = $loginUsername;
    $GLOBALS['MM_UserGroup'] = $loginStrGroup;

    //register the session variables
    session_register("MM_Username");
    session_register("MM_UserGroup");


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


 
Old March 25th, 2004, 06:42 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Cross post to http://p2p.wrox.com/topic.asp?TOPIC_ID=11496

Please *do not* cross post on P2P forums. Your post will be read no matter how many times you post it.

Keeping P2P the great place it is :),

----------
---Snib---
----------

<><





Similar Threads
Thread Thread Starter Forum Replies Last Post
redirecting users t0r3ad0r ASP.NET 1.0 and 1.1 Professional 1 October 5th, 2006 10:32 PM
Determine logged on users markw707 Access 1 January 21st, 2005 01:59 AM
Redirecting Users anshul Pro PHP 1 April 3rd, 2004 04:31 PM
Help with redirecting users Sach Classic ASP Databases 1 January 16th, 2004 12:29 PM
Redirecting logged in users zicaden Beginning PHP 3 September 6th, 2003 02:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.