Jump to content

[SOLVED] login system problems


Stickybomb

Recommended Posts

I am working on a login system.

 

this is the code i am using to validate and process the login.

 

<?php
if($_POST['submitted']=='yes'){
$user				= $_POST['userid'];
$pass				= $_POST['pass'];
$remember			= $_POST['remember'];

require_once('inc/sentry.php');
require_once('inc/validator.php');
$sentry		= new Sentry;
$validate	= new Validator;

//check if empty
$validate->validateGeneral($user, "* You must enter a UserID<br /><br />");
$validate->validateGeneral($user, "* You must enter a Password<br /><br />");

//check length minimums
$validate->validateMinLen($user, '3', "* UserID must be at least 3 characters<br /><br />");
//$validate->validateMinLen($pass, '6', "* Password must be at least 6 characters<br /><br />");

//check length maximums
$validate->validateMaxLen($user, '30', "* UserID can not be more than 30 characters<br /><br />");
$validate->validateMaxLen($pass, '16', "* Password can not be more than 16 characters<br /><br />");

//check for password format
//$validate->validateNumber($pass, "* Your Password must contain at least 1 letter and 1 number toataling 6-16 characters in length.<br /><br />");
//$validate->validateTextOnly($pass, "* Your Password muct contain at least 1 letter and 1 number toataling 6-16 characters in length.<br />");

if($validate->foundErrors()){
	echo '<div id="errors"><p>';
	$validate->listErrors($delim = '<br />');
	echo '</p></div>';
	include('templates/loginform.tpl');
	exit();
}else{
	echo 'Processing Login...';

	//strip slashes and spaces
	$user 		= $validate->cleanValue($user);
	$pass 		= $validate->cleanValue($pass);

	//strip headers
	$user 		= $validate->stripHeaders($user);
	$pass 		= $validate->stripHeaders($pass);

	//validate login attempt
	$sentry->checkLogin($user,$pass,$remember);
}
}else{
include('templates/loginform.tpl');
}
?>

 

basically if there are errors during validation it will display the errors above the login form, if there are no errors it should process the login.

 

for some reason it is ignoring the else statement and displaying validation errors and still carrying out processing the login.

 

anyone help me to figure this out

thanks

Link to comment
Share on other sites

$user				= $_POST['userid'];
$pass				= $_POST['pass'];
$remember			= $_POST['remember'];

 

 

might want to put some injection protection on that...

 

 

$user				= mysql_real_escape_string($_POST['userid']);
$pass				= mysql_real_escape_string( $_POST['pass']);
$remember			= mysql_real_escape_string($_POST['remember']);

 

 

Try changing that very last Else to an

ElseIf(!($_POST['submitted']=='yes'){
include('templates/loginform.tpl');
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.