This is a discussion on "PHP Login" within the PHP Forum section. This forum, and the thread "PHP Login are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP Login
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
||||
|
PHP Login
Hey all. Following this tutorial:
http://www.phpeasystep.com/workshopview.php?id=6 1. Am I using PHP 4 or PHP 5? How can I find out? 2. Try going here: http://www.jackfranklin.co.uk/PHP%20...main_login.php and use the username john and the password 1234. I get lots of errors! The code for the check_login.php is:
Thanks Jack
__________________
Resources Administrator
Grilling Gurus - Interviews with the Best Web Designers and Developers in the Industry Got a Question for Ryan Carson and his Web Design/Development team Carsonified? Jack Franklin - My Blog (It's a Pen in My Mouth BTW)
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
|
|
|
|
||||
|
Re: PHP Login
What are the errors mate? They can help a lot in the debugging process.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: PHP Login
There are no errors in the PHP script. HTML is also OK. Check the SQL login data....
Otherwise I can't see any problems.
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
|
||||
|
Re: PHP Login
The warnings I get are:
Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /home/jackfran/public_html/PHP Stuff/PHPLogin/checklogin.php:9) in /home/jackfran/public_html/PHP Stuff/PHPLogin/checklogin.php on line 35 Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/jackfran/public_html/PHP Stuff/PHPLogin/checklogin.php:9) in /home/jackfran/public_html/PHP Stuff/PHPLogin/checklogin.php on line 35 Warning: Cannot modify header information - headers already sent by (output started at /home/jackfran/public_html/PHP Stuff/PHPLogin/checklogin.php:9) in /home/jackfran/public_html/PHP Stuff/PHPLogin/checklogin.php on line 37 Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0
__________________
Resources Administrator
Grilling Gurus - Interviews with the Best Web Designers and Developers in the Industry Got a Question for Ryan Carson and his Web Design/Development team Carsonified? Jack Franklin - My Blog (It's a Pen in My Mouth BTW)
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
|
|
||||
|
Re: PHP Login
I'd just like to suggest filtering the input, otherwise this script is vulnerable to SQL Injection i think changing the post part to the following should work:
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: PHP Login
OK, I got it:
Your problem is here:
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
|
||||
|
Re: PHP Login
Would it next
__________________
The Net is Dying | All Web Chat Forum - All the Web Chat you'll ever need Simon Bennett's Blog
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
|
|
||||
|
Re: PHP Login
Thanks for the help guys. What can I do to correct it? simon- I dont quite understand what you are saying?
Cheers Jack
__________________
Resources Administrator
Grilling Gurus - Interviews with the Best Web Designers and Developers in the Industry Got a Question for Ryan Carson and his Web Design/Development team Carsonified? Jack Franklin - My Blog (It's a Pen in My Mouth BTW)
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
|
|
||||
|
Re: PHP Login
Thats how you start a session
__________________
The Net is Dying | All Web Chat Forum - All the Web Chat you'll ever need Simon Bennett's Blog
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
|
|
||||
|
Re: PHP Login
I think Simon means put this in:
|
|
||||
|
Re: PHP Login
OK, Let me explain in what I hope is "normal person" english:
The headers of a HTML page get sent before ANY of the content. So, if you want to set any information in the header using PHP (ex: using the header() function or the session_*() functions), you have to do it before you output anything to the page (using echo() or print() or normal HTML output). So, when you try to start a session and change the header, PHP throws an error, because the header has already been sent to the client and the server can't make any more changes. Hope that makes at least a bit of sense, feel free to throw down some more ?'s....
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
|
||||
|
Re: PHP Login
I think I get it. So would I put the code Marc posted at the very very top of my page, before any other code? or would I move all the code before the <html....?
Thanks for the help! Jack
__________________
Resources Administrator
Grilling Gurus - Interviews with the Best Web Designers and Developers in the Industry Got a Question for Ryan Carson and his Web Design/Development team Carsonified? Jack Franklin - My Blog (It's a Pen in My Mouth BTW)
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
|
|
||||
|
Re: PHP Login
that's it! you catch on fast...
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
|
||||
|
Re: PHP Login
Great Thanks, I'll try it when I get the chance and report back...
__________________
Resources Administrator
Grilling Gurus - Interviews with the Best Web Designers and Developers in the Industry Got a Question for Ryan Carson and his Web Design/Development team Carsonified? Jack Franklin - My Blog (It's a Pen in My Mouth BTW)
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
|
|
||||
|
Re: PHP Login
Might I just say, it would be a lot easier to put Marc's code in file and "include()" it in every page.
That way, if you need to add or change something, you simply change one file.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: PHP Login
All the php on my sites is include
__________________
The Net is Dying | All Web Chat Forum - All the Web Chat you'll ever need Simon Bennett's Blog
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
|
|
||||
|
Re: PHP Login
Yay it works. Thanks. Try going to http://www.jackfranklin.co.uk/PHP%20...main_login.php
Use a username: John password: 1234 Ok, but I now have a query. If I add another row in the table with another username and password, will it still work, or do I need to change the code? And also, how would the following work: 1. I have a page/directory/area in my site which I only want logged in users to be able to access. EG, users.php is a page only those logged in can view. How would I make it so that only logged in people could view, but if you typed in www.address.com/users.php it would not work? Sorry for the crappy explanation, hope you understand! Thanks for the help so far guys Jack EDIT - I tried entering another row and it works But I now have more: How would I create a button that would say 'Log Off' and log the user off the system? Is there a way to make a small piece of text saying 'x users online'? I did find a tutorial but it has confused me I don't get that at all - where did those values in the tables come from? Thanks Jack
__________________
Resources Administrator
Grilling Gurus - Interviews with the Best Web Designers and Developers in the Industry Got a Question for Ryan Carson and his Web Design/Development team Carsonified? Jack Franklin - My Blog (It's a Pen in My Mouth BTW)
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Last edited by Jack Franklin; Oct 9th, 2007 at 19:38. |
|
||||
|
Re: PHP Login
Quote:
Quote:
You might want to check out this link for a membership system http://www.devarticles.com/c/a/PHP/C...ship-System/1/ |
|
||||
|
Re: PHP Login
To logout, put a link to "logout.php"
and have the page contain:
You might want to add some text etc.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: PHP Login
Here is an example how you could check to see if a user is logged in
On you protected page you could put something like this. This would check to see if the user has logged in (if they have a session would have been registered) and if not it displays the login page
|