Hello
I have just started to look in to PDO as I have heard that it is a better alternative to the mysql commands. I currently have a simple login system that checks the password and username against a sql database and grants you access if both the username and password is correct. I would now like to add the ability to register to the site. How would I go about letting the user enter his own username and password to be stored in the database so that he/she can log in later? Some help would be much appreciated.
-Tim
PHP PDO database intereaction
Page 1 of 15 Replies - 308 Views - Last Post: 01 October 2012 - 06:57 AM
Replies To: PHP PDO database intereaction
#2
Re: PHP PDO database intereaction
Posted 01 October 2012 - 06:11 AM
tim9009, on 01 October 2012 - 03:02 PM, said:
How would I go about letting the user enter his own username and password to be stored in the database so that he/she can log in later?
I’d go for the straight approach. let the user enter a username and password, and insert it into the DB after validation (minimum string length, character types used, etc.).
one more comment to the DB. setting up the table properly is important. you need indexes on the name and password hash columns, the name column must be at least unique (or the primary key). reason being that if the name column is set to UNIQUE, it will lead to a database insertion error if the name already exists, which you can use to tell the user that his name is already in use. indexed columns are good for speed. and that you need to hash the password should be obvious.
#3
Re: PHP PDO database intereaction
Posted 01 October 2012 - 06:23 AM
I see, thank you. Now, could you please explain to me (or direct me to some one) how I would write the code for this? Please keep in mind that I am fairly new to PDO and PHP in general.
-Tim
-Tim
#4
Re: PHP PDO database intereaction
Posted 01 October 2012 - 06:32 AM
how far have you gotten into PDO yet? (or asked the other way round, do you know the PDO basics?)
a tutorial I wrote about logging in with PDO: http://www.dreaminco...-point-of-view/
a tutorial I wrote about logging in with PDO: http://www.dreaminco...-point-of-view/
#6
Re: PHP PDO database intereaction
Posted 01 October 2012 - 06:57 AM
As I said I have made and understand a simple login system. It is similar to the one that you show in your tutorial. So yes, I would say that I know the basics of PDO.
-Tim
-Tim
This post has been edited by tim9009: 01 October 2012 - 06:57 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|