Page 1 of 1
login - function
Posted: Fri Jul 23, 2010 4:08 am
by Tinebn
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
Re: login - function
Posted: Fri Jul 23, 2010 7:17 pm
by yacahuma
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
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");
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
Re: login - function
Posted: Sat Jul 24, 2010 3:03 am
by Tinebn
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 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");
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
//

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 ??

))