5 Replies - 703 Views - Last Post: 01 October 2012 - 06:57 AM Rate Topic: -----

#1 tim9009  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 73
  • Joined: 01-October 10

PHP PDO database intereaction

Posted 01 October 2012 - 06:02 AM

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

Is This A Good Question/Topic? 0
  • +

Replies To: PHP PDO database intereaction

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,319
  • Joined: 08-June 10

Re: PHP PDO database intereaction

Posted 01 October 2012 - 06:11 AM

View Posttim9009, 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?

Id 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.
Was This Post Helpful? 2
  • +
  • -

#3 tim9009  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 73
  • Joined: 01-October 10

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
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,319
  • Joined: 08-June 10

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/
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6075
  • View blog
  • Posts: 23,540
  • Joined: 23-August 08

Re: PHP PDO database intereaction

Posted 01 October 2012 - 06:33 AM

Moved to PHP
Was This Post Helpful? 0
  • +
  • -

#6 tim9009  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 73
  • Joined: 01-October 10

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

This post has been edited by tim9009: 01 October 2012 - 06:57 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1