Login pages... (quickie)
Moderator: General Moderators
-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
Login pages... (quickie)
Hi. <3 I'm currently learning how to make a login page. Now I've got a question.
The place I'm learning from is http://www.evolt.org/article/Creating_a ... index.html
Right about at this part of the page:
"Check Client
Next we need to check if the client is already logged in or not. If they are, leave them be, if they're not, pop up a login form:"
I'm wondering if I have to copy-paste that onto each page I do. That's all, quick question.
The place I'm learning from is http://www.evolt.org/article/Creating_a ... index.html
Right about at this part of the page:
"Check Client
Next we need to check if the client is already logged in or not. If they are, leave them be, if they're not, pop up a login form:"
I'm wondering if I have to copy-paste that onto each page I do. That's all, quick question.
Hmm, That page is an example of the basics of authentication/login with PHP. It's not a complete login system. There could be many ways of implementation and the script isn't the best because it stores passwords in clear text. You'll need to change quite a bit to make it work in the real world.
To answer you question in brief, yes you'll need to check on everypage that you want to protect to see if the user is logged in. Would I use their exact code? No.
Experiment with the code. Post you questions here.
To answer you question in brief, yes you'll need to check on everypage that you want to protect to see if the user is logged in. Would I use their exact code? No.
Experiment with the code. Post you questions here.
-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
Editted out in case some folks try to hax0r me. Seriously. o_O;;
Last edited by Mightywayne on Fri Apr 06, 2007 12:22 pm, edited 1 time in total.
-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
Editted out in case some folks try to hax0r me. Seriously. o_O;;
Last edited by Mightywayne on Fri Apr 06, 2007 2:17 pm, edited 1 time in total.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
If you have any space before <?php that is output and the first bit of output triggers the headers to be sent. Here are some examples:
Code: Select all
<?php
// headers sentCode: Select all
<?php
// headers not yet sentCode: Select all
<?php
echo 'a';
// headers sentCode: Select all
<?php
?> <?php
// headers sentCode: Select all
<!-- comment --><?php
// headers sent-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
Editted out in case some folks try to hax0r me. Seriously. o_O;;
Last edited by Mightywayne on Fri Apr 06, 2007 2:17 pm, edited 2 times in total.
-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
Ahh! The LINE! Aha. Gotcha. I thought you meant spaces like . Well. Okay. Thanks.
If I have more questions, I guess I'll use this thread for it.
Edit: (didn't want to bump) I always do injection stuff last. xP Thanks for the concern though, Matt.
Edit: (didn't want to bump) I always do injection stuff last. xP Thanks for the concern though, Matt.
Last edited by Mightywayne on Sun Jan 14, 2007 9:15 pm, edited 1 time in total.
Code: Select all
username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM user WHERE username='$username' and password='$password'";
$result = mysql_query($sql);-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
Editted out in case some folks try to hax0r me. Seriously. o_O;;
Last edited by Mightywayne on Fri Apr 06, 2007 2:18 pm, edited 1 time in total.