|
-
Aug 2nd, 2004, 04:55 PM
#1
Thread Starter
PowerPoster
noob to php :)
ok, i have basic PHP knowledge and fairly decent mysql, i'm after creating
a user login area, could someone point me in the right direction, or at least in the direction of a guide 
PINO-
-
Aug 2nd, 2004, 05:40 PM
#2
It depends on how advanced you want to make it. The way I usually do it is to include a file called which authenticates the user in every php page that I want to protect.
The easiest way of doing this is using PHP's built in session functions. The reason you need sessions is becuase once the user has logged on you don't want to keep asking them for their details again.
The authentication file may look something like this:
PHP Code:
<?php
session_start ();
if (! isset ($_SESSION['user_logged_on'])) {
if (!isset ($_POST['submitted'])): ?>
<p>Enter your user name and password to contuinue:</p>
<form method="post">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" name="subbmitted" vaelue="Log On" />
</form>
<?php
exit;
else {
/* check username and password here with mysql*/
/* if they are correct - set the session variable */
$_SESSION['user_logged_on'] = true;
}
}
?>
I don't have time tto write complete code, but itt should give you an idea. The following links may also help you:
Sessions in PHP
PHP/MySql Functions
Using HTTP Forms
-
Aug 3rd, 2004, 05:48 AM
#3
Thread Starter
PowerPoster
thanks,
sessions will not really be need at the moment, i'm trying to learn how to do 2 things
1) read from database and display on page
2)if admin enters the 'login area' can edit database
what it basicly is is so people can look at the progress of there work and how far it has come along!
thanks
do you know of the most basic mysql/php guide
-
Aug 3rd, 2004, 09:52 AM
#4
Frenzied Member
www.php.net is always a good reference.
-
Aug 3rd, 2004, 12:20 PM
#5
Thread Starter
PowerPoster
yea its not bad, but i had a REALLy simple guide which just showed you how to edit,add,delete records from the database! dont suppose you've sen one around?
-
Aug 3rd, 2004, 12:40 PM
#6
I don't know of any online tutorials. I read the manuals mostly. The PHP manual is excellent and the MySql manual isn't too bad either.
I would recommed the Wrox Beginning PHP books - they give many examples and also go thorugh all the language constructs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|