Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases 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:28 PM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Redirecting User to different pages

Hi, I am trying to read in a testscore from the query ($LoginRS__query=sprintf) below and use this to redirect the users when they log onto the site to the pages in the if/else statements below. I am trying to replace ($MM_redirectLoginSuccess = "modeselection.php";) line with the if/else statement. The if/else statement is working fine if I force the value(give testscore a value of 1). 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 29th, 2004, 04:38 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If your test scores are submitted via a web form, be sure you access them via the appropriate superglobal array -- $_GET or $_POST.

More info here:
  http://p2p.wrox.com/archive/beginnin...2002-11/17.asp
  http://www.google.com/search?q=regis...e:p2p.wrox.com


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to persist Context.User across pages? musa BOOK: ASP.NET Website Programming Problem-Design-Solution 5 January 4th, 2008 12:07 AM
Restricting the user from opening pages gaurav_jain2403 ASP.NET 1.0 and 1.1 Professional 1 January 19th, 2007 11:12 AM
Redirecting a user after loggin in hasanali00 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 April 19th, 2005 07:45 PM
nearsighted user cannot default pages to 640x480 HowardNYC Forum and Wrox.com Feedback 9 September 24th, 2004 01:36 PM





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