hi
I have made a simple login function - php+mysql , works fine !
my question is
when I login I get the site I have put in my code... and nothing else !
this site login has what i'am looking for... some pages everybody can see- others not and then there is the privacy site.
Do not understand the functions........ Then I can't program the login for my site
hope somebody cann give me the "picture" have is the data flows ??
Tine
login - function
Moderator: General Moderators
Re: login - function
I dont really understand where are you lost
You present a form in the login page. When the form is submitted you check that username and password exists in the database. If they exist you create a session
at the top of every page you check if the session is set
remember if you save an object in the session you have to include the session declaration before checking the session.
Thats it. There is not much else
You present a form in the login page. When the form is submitted you check that username and password exists in the database. If they exist you create a session
Code: Select all
if (credential in database)
{
session_start()
$_SESSION['user'] = a variable or an object containing user data
header("Location: inside.php");
}
at the top of every page you check if the session is set
Code: Select all
session_start();
if (!isset($_SESSION['user']) )
header("Location: login.php");
Thats it. There is not much else
Re: login - function
//yacahuma wrote:I dont really understand where are you lost
You present a form in the login page. When the form is submitted you check that username and password exists in the database. If they exist you create a sessionCode: Select all
if (credential in database) { session_start() $_SESSION['user'] = a variable or an object containing user data header("Location: inside.php"); }
at the top of every page you check if the session is setremember if you save an object in the session you have to include the session declaration before checking the session.Code: Select all
session_start(); if (!isset($_SESSION['user']) ) header("Location: login.php");
Thats it. There is not much else
maybee more easy than I think
So every site I want to be a loginsite I give the page check session syntax in top... ??
The database and the privat data "automatic" shows the content from the database on site after the ID - login ?
the database is not controlling anything only content - it is the top code syntax who does the login work ??