PHP MySQL login page won't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following is text created by dreamweaver CS3 to login a user.  There is
something wrong with it because when I enter the appropriate information
into my fields, I get sent to failed.php instead of home.php (both were
specified by me).  I have gone over the code as best I can, but I am not
nearly skilled enough to figure out what the hell the problem is.  Does
anybody see anything wrong with this?

_________________

<?php require_once('Connections/connReelBadd.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['Login'])) {
  $loginUsername=$_POST['Login'];
  $password=$_POST['Password'];
  $MM_fldUserAuthorization = "numAccessLevel";
  $MM_redirectLoginSuccess = "home.php";
  $MM_redirectLoginFailed = "failed.php";
  $MM_redirecttoReferrer = true;
  mysql_select_db($database_connReelBadd, $connReelBadd);
  	
  $LoginRS__query=sprintf("SELECT txtLogin, txtPassword, numAccessLevel FROM
screennames WHERE txtLogin=%s AND txtPassword=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password,
"text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $connReelBadd) or
die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'numAccessLevel');
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && true) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<?php echo
$loginFormAction; ?>">
  <table width="300" border="0" cellspacing="0" cellpadding="0">
    <caption>
      Hey, you! Login.
    </caption>
    <tr>
      <th scope="row">Login Name</th>
      <td><input type="text" name="Login" id="textfield" /></td>
    </tr>
    <tr>
      <th scope="row">Password</th>
      <td><input type="password" name="Password" id="textfield2" /></td>
    </tr>
    <tr>
      <th colspan="2" scope="row"><input type="submit" name="Login"
id="Login" value="Do it." /></th>
    </tr>
  </table>
</form>
</body>
</html>

________________________________________

Thanks in advance!
~Don

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux