Quantcast
Viewing all articles
Browse latest Browse all 114192

Re: Error Messages When Logging Into My Site

Have another go with the code below. It works for me (test it both locally and remotely).

 

 

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

<?php

if (!function_exists("GetSQLValueString")) {

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

{

  if (PHP_VERSION < 6) {

    $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 = "home.php";

  $MM_redirectLoginFailed = "loginfail.php";

  $MM_redirecttoReferrer = false;

  mysql_select_db($database_drama_database, $drama_database);

 

  $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",

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

  

  $LoginRS = mysql_query($LoginRS__query, $drama_database) 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>

<html>

<title>Drama Database - Login</title>

<head>

<meta http-equiv="charset=UTF-8">

<link href="images/favicon.ico" rel="icon" />

<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>

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

</head>

<body>

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

<!--visual -->

<br>

<br>

<br>

<div align="center">

<!--ACS Logo -->

<img src="images/logo_acs_egham.gif" width="387" height="59" /><br>

<!--Drama Logo -->

<br>

<img src="images/bglogin.jpg" alt="Acs-Egham International School" width="246" height="153">

<br>

<!--Title -->

<h2>Drama Database Login</h2>

</center>

</div>

<table width="154" border="0" align="center">

<tr>

<td width="148">Username:<br />

<span id="sprytextfield1">

<label for="UserName"></label>

<input type="text" name="UserName" id="UserName" />

<span class="textfieldRequiredMsg">A value is required.</span></span></td>

</tr>

<tr>

<td> </td>

</tr>

<tr>

<td>Password:<span id="sprytextfield2"><br />

<label for="Password"></label>

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

<span class="textfieldRequiredMsg">A value is required.</span></span></td>

</tr>

<tr>

<td></td>

</tr>

<tr>

<td align="center"><input type="submit" name="LoginButton" id="LoginButton" value="Login" /></td>

</tr>

<tr>

<td></td>

</tr>

</table>

</form>

<script type="text/javascript">

var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");

var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");

</script>

</body>

</html>


Viewing all articles
Browse latest Browse all 114192

Trending Articles



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