Edit
by Kanwal Naz - 9 years ago (2015-04-01)
user authorization process
| 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 require_once('Connections/config.php');
@session_start();
error_reporting(E_ALL ^ E_NOTICE);
if(isset($_GET['logout'])){
@session_destroy();
$messageUser="You have been logged out successfully";
?> <script type="text/javascript">
alert("<?=$messageUser?>")
</script>
<?php redirect('login.php');
}
if(isset($_POST['login_submit'])){
$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'];
redirect('dashboard.php');
}
elseif($rows_users['ustatus'] == 2)
$_SESSION['messageUser']="You are banned user";
else
$_SESSION['messageUser']="you are not activated yet";
}
else
$_SESSION['messageUser']="user does not exists";
}
?> |
Ask clarification
2 Recommendations
tinyUGatMs: Manage users and groups of events in a database
This package can manage users and groups of events in a database.
It can manage records of users and user groups associated to events.
The package can create or update given user records. Each user belongs to a group of recurring events.
It can also create or update recurring event records to be associated with groups of users.
| by zinsou A.A.E.Moïse package author 6835 - 7 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 class can access MySQL databases and execute common queries. Currently it can:
- Connect to a given MySQL host and access a given database
- List all tables in the accessible databases
- Get the columns of a given table
- Compose and execute SELECT queries to a given table getting specific fields by a given sorting order returning the results into a single array
- Search for given table records that match given conditions
- Insert table records with given field values
- Update table records with given field values and conditions
- Delete table records that match a condition
- Create table records for a new user with a password
- Authenticate a given user with a password in the users table
- Change a given user password in the users table
- Update or delete given user records in the users table
- Read the text contents of files in the format CSV, PDF or Microsoft Word
- Write plain text or CSV files
- Rename or delete files
- Get the list of files from a directory
- Etc..
| by Justin Eldracher package author 160 - 9 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. |