Step by Step Guide for PDO registration form Development
Caution: In this post, I am not going to explain PDO or the benefits/uses of it. As I’m sure, if you landed on this page, you already have good knowledge of basic terms generic viagrageneric viagra.
PDO Registration Form Development
- Open an editor to start writing your php code. I am using Eclipse.
- Follow the below basic code, to connect database.
srefidensi 2019 Note: If you don’t have any database yet, or want to create new db. Go to: http://localhost/phpmyadmin/
Click “New” to create a new database from phpMyAdmin diamond 7.
- Successful connection establishment result will be as follows:
- As shown in the above screenshot, you have to goto localhost/foldername/yourfilename.php In my case, I have created the folder AU (For AustraliaUnwrapped) and file name is index.php
If you are a new coder, your first working code will give you BIG happiness ha ha amoxicillin diabetes
Creating Users Table
Let’s check the database part now.
Create a table “users” with a required number of fields. Suppose, I need 7 fields. Such as Users ID, username, email, password, First Name, Last Name, and City.
You can decide, what information you want to fetch and store. You can ask DOB etc. too.
Here is my table’s screenshot
Create a Simple HTML Form
Create a simple HTML Form for your required fields.
Here is mine:
PDO registration Form Output is as follows:
Here is the complete PDO for above screenshot:
If you have any questions, feel free to ask in comments 🙂
- Go back to line 4 for placing if condition. So, we can add function for the register button. Such as if register button clicks, what should happen?
- The attached database should store the data, agree?
Here is the complete source code for your consideration. As it was about PHP only so not enough CSS inserted.
In this source file, you will get 3 different code files. One for main index page, 2nd for a profile page and 3rd for logout page.
Read the code and ask questions if you have any.
This is the most simplest code, in which we are fetching data from using the registration form and storing it into the database. As we have established a database connection.
Once, User gets registered. He/she can get login by using correct info. Finally, there is a logout link too.
Main Image Source : Pixabay