We have got the database, now we need to create a mechanism by which the user can 'register' or add his details to access later.
First, we can use the input function to get the values for username and password.
Simple, right. However, the real problem starts after this. This data will be deleted when this program is closed. So, how can the user login next time ? Remember the database we created. We are now going to store this data in that database to use next time.
To store the value in the database, we use the cursor.execute() function. Here's how that goes:
The execute function executes the SQL statement given inside the brackets. Here, we are using the Insert statement to add the username and password to the database. Let's see if it works.
We didn't get any error, so there is no problem. Let's check whether it is updated in the database.
It is updated ! However, here is where another problem creeps in. What if two people use the same username ? We need to make sure that doesn't happen and let's do that in the next post.
For the previous post: The PYgrammer: LOGIN SYSTEM #1: Database Creation
For the next post: The PYgrammer: LOGIN SYSTEM #3: Checking for repeating Username
Comments
Post a Comment