parfaitmacaron — 2013-03-10T15:03:19-04:00 — #1
I need to create a PHP register and login form for my website so that only those users using my system can log in after they've registered.
Their details will be stored in a database which I have yet to set up.
I am clueless with how to go about this, I have not used PHP at all. Do I need to identify the relationships/tables in my database first (MySQL/PHPMyAdmin) or can I build this register box and login box first?
Can somebody please explain how to go about this?
hotshot060 — 2013-03-10T20:01:48-04:00 — #2
Well you can do it with many ways , the easiest is you can code your action php file which connects to the database stores or grabs data from database and accordingly perform register or login whatever you want . Well there is an another method in which you could do these tasks on the same page itself also using '$_GET' superglobal whenever someone clicks submit , it goes and do specified task and you are done .
captainccs — 2013-03-10T22:45:15-04:00 — #3
If you have never coded php and are "clueless with how to go about this" you have taken on a fairly complex bit of scripting.
You don't have to use a database, you could store the usernames and passwords in a file and that is a lot simpler. Don't store the passwords in the clear, use something like md5() to encode them.
You do need to use sessions, preferably with cookies, to remember the user as he goes from page to page.
The workflow is that at the top of the restricted page (pages) you ask if the visitor has logged in by checking a session variable. If yes, show the working page. If not, show the log in page. If he logs in properly you set the session variable accordingly.
But it gets more complicated because the user should be able to change his password and to do so you should authenticate it by email.
chrisranjana — 2013-03-11T04:52:28-04:00 — #4
Our very own sitepoint has a tutorial regarding php user registration (http://www.sitepoint.com/users-php-sessions-mysql/)
parfaitmacaron — 2013-03-12T20:14:21-04:00 — #5
Thank you for the link! I was reading that earlier on this week.