Forums

PHP

This topic is locked

PHP/MySQL login.

Posted 25 Sep 2007 16:12:57
1
has voted
25 Sep 2007 16:12:57 Stephen Smith posted:
I've been trying to learn to use DWMX04 Server Behaviours to create a login system and have been following the guidance provided by the Allan Kent article purchased from this site. I have run into a problem in that on testing the first stage in which my Username and Password are to be tested against prepared entries on my database the system just stops and the progress bar just flickers.
I have tested the MYSQL connection within DWMX and that's fine.

The code that DWMX has written for me is as followsa:

<?php require_once('../Connections/Login.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['textLogin'])) {
$loginUsername=$_POST['textLogin'];
$password=$_POST['textPassword'];
$MM_fldUserAuthorization = "user_id";
$MM_redirectLoginSuccess = "users.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_Login, $Login);

$LoginRS__query=sprintf("SELECT user_login, user_password, user_id FROM loggers WHERE user_login='%s' AND user_password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $Login) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {

$loginStrGroup = mysql_result($LoginRS,0,'user_id');

//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 );
}
}
?>


It is supposed to take submissions from a form, check them against my database and then redirect the browser to one or other pages. Can anyone think why this won't function for me?

Reply to this topic