PHP Classes

user authorization: user authorization process

Recommend this page to a friend!
  All requests RSS feed  >  user authorization  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

user authorization


Picture of Kanwal Naz by Kanwal Naz - 8 years ago (2015-04-01)

user authorization process

This request is clear and relevant.
This request is not clear or is not relevant.


I wish to learn the user authorization process with login attempts check, I have created a simple user login function that on successful login redirect to welcome page but this didn't restrict wrong submitted password. my code is as under: <?php

error_reporting(E_ALL ^ E_NOTICE);
$messageUser="You have been logged out successfully";


		<script type="text/javascript">


	$userName	= 	$_POST['username'];
	$uPassword	=	$_POST['password'];
	//$hashed    	= 	hash('sha512', $uPassword);

	$_SESSION['messageUser'] = "";

	$sql	=	"SELECT * FROM users WHERE username= '$userName' AND password= '$uPassword'";
	$res	=	mysql_query($sql) or die('1login'.mysql_error());
	if(@mysql_num_rows($res) > 0 ){
		$rows_users	=	mysql_fetch_assoc($res);			
		if($rows_users['ustatus'] == 1){		
				$_SESSION['myId'] 		= $rows_users['id'];	
				$_SESSION['myName'] 	= $rows_users['username'];
				$_SESSION['myPass'] 	= $rows_users['password'];
				$_SESSION['myType']		= $rows_users['utype']; 		
				$_SESSION['myCompany'] 	= $rows_users['com_id'];	
				$_SESSION['myBranch'] 	= $rows_users['br_id'];	
				$_SESSION['myStatus'] 	= $rows_users['ustatus'];
		elseif($rows_users['ustatus'] == 2)				
			$_SESSION['messageUser']="You are banned user";
			$_SESSION['messageUser']="you are not activated yet";
		$_SESSION['messageUser']="user  does not exists";


Ask clarification

2 Recommendations

tinyUGatMs: Manage users and groups of events in a database

This recommendation solves the problem.
This recommendation does not solve the problem.


Picture of zinsou A.A.E.Mo´se by zinsou A.A.E.Mo´se package author package author Reputation 5840 - 6 years ago (2017-07-20) Comment

tinyGatMs package is simple users and groups recurring access time management system. technolgies used: -PHP of course -MySql -AJAX(JAVASCRIPT) -HTML5 -for the css it's minimalist you will see what to do with that

Features: -Class for groups management(validation, creation, suppression) -Class for users management(registration, validation, creation, suppression) -Management area based on user's role, actually it is set on Admin allowed only(fully used of ajax only) -Users registration with ajax using PDO to connect to MySql *check of already used mail or already used username (ajax) *send of validation mail(ajax) -Users connexion with ajax using PDO to connect to MySql *check of username existence(ajax) *check of true password(ajax) *check of access time (ajax) with message to tell you when to connect if you can't at the moment you try. *not register? link *forget password link -Users password recovering page and reset mail sending using ajax *mail prompt *password changing after mail validation with unique id -Management of users *Edit properties like activation statut,role,password,group for access time etc... *Add a new user *Delete an user -Management of Groups *Edit properties like name,description,access time,access time recurrence,starting date to apply the access time, etc... *Add a new group *Delete an existing group.

MySQL Database Library: Access MySQL databases and manipulate files

This recommendation solves the problem.
This recommendation does not solve the problem.


Picture of Justin Eldracher by Justin Eldracher package author package author Reputation 140 - 8 years ago (2015-06-22) Comment

I have a few methods for dealing with users in my MySQL database class. I currently use the MySQL password() function on my passwords, though, so you might not want to use it if you are storing plain text.

Anyway, the authorize("user", "pass") method check to see if the given username & password exist in the users table of the database and if they are unique. If so, it returns an associative array of that user, but if not it returns false.

Hope that helps.

Recommend package