Main Home | Scholarships | Ask The Dean | Fun Quizzes | Buy Services | Blog


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with php login script
05-12-2012, 10:37 PM
Post: #1
I need help with php login script
I am a beginner in php and i find it difficult to integrate a login system in my website, please can somebody help me with that.


I know there are just few people in this forum but I hope to receive a reply even from the admin.
Find all posts by this user
Quote this message in a reply
05-12-2012, 11:35 PM
Post: #2
RE: I need help with php login script
In php, the best way to write a simple login script with validate and authentication with data source (eg. file system or database) is by using some built in php functions and variables.

Php POST and GET variables are use to get submitted data from form or Url. These data can be match with a user login identity data and the result will determine if the user will be given access or not.

A simple php code is shown below
PHP Code:
$username $_POST['username'];
$password $_POST['password'];

// insert code for database connect
 
$connection mysqli_connect(SERVER_NAMEUSER_NAMEPASSWORD 
 or die (
'Could not connect to the Server :' mysql_error());
 
$database mysqli_select_db($connectionDATABASE_NAME) or die('Could not connect to the database');


$query 'SELECT * FROM login WHERE username = "$username" AND password = "$password" LIMIT 1';
$result mysql_query($query);

if(
$result)
{
   
// Grant access to the user
}else
{
    
// Don't grant access. You can also redirect the user in the login page with error message


This is a simple idea, you can work and expand the idea to suit your application. Hope it helps
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)