How to Create Registration Page in PHP/MySQL

Related code: How to Create Secure Registration Page in PHP/MySQL This is a simple tutorial that will teach you on how to create a simple registration form using PHP/MySQL with JavaScript for input validation. This tutorial will not teach you on how to create a good design but rather to give you knowledge on how to create a fully functional registration form.

Creating our Table

First we are going to create our database which stores our data. To create a database: 1. Open phpmyadmin 2. Click create table and name it as simple_login. 3. Then name the database as "registration". 4. After creating a database name, click the SQL and paste the below code. CREATE TABLE IF NOT EXISTS `member` ( `mem_id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(30) NOT NULL, `password` varchar(30) NOT NULL, `fname` varchar(30) NOT NULL, `lname` varchar(30) NOT NULL, `address` varchar(100) NOT NULL, `contact` varchar(30) NOT NULL, `picture` varchar(100) NOT NULL, `gender` varchar(10) NOT NULL, PRIMARY KEY (`mem_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

Creating The Form

Next step is to create a form and save it as index.php. To create a form, open your HTML code editor and paste the code below after the tag. Registration
First Name:
Last Name:
Gender:
Address:
Contact No.:
Username:
Password:

Creating our Connection

Next step is to create a database connection and save it as "connection.php". This file is used to connect our form to database. This file serves as a bridge between our form and our database.

Writing Our Save Script

Next step is to create our script that save our input data to database and save it as code_exec.php.

Validating The Input

To add some input validation using javascript, add the code below in the head tag of your index.php file. Input validation is used to make sure that all input field are filled out before saving the to database. That's it! You've been successfully created your simple registration form with javascript for the input validation. Registration using php, input validation using javascript. Update: I have created another tutorial using a server side validation. And I am also using PDO to secure the registration page. Click here to see my latest update How to Create Registration Page in PHP/MySQL Using PDO Query. Related code: How to Create Secure Registration Page in PHP/MySQL

Comments

Submitted byMahmoud Nagy (not verified)on Sat, 04/12/2014 - 03:18

the record doesn't save in database ???
Submitted byAyub Azam (not verified)on Sun, 04/13/2014 - 02:25

Thank you for this article. it'll help me to connect my php form to database. need more help in php mail me at [email protected]
Submitted bySimon S. (not verified)on Wed, 04/16/2014 - 08:12

Really nice tutorial, however, there is a huge bug! If you leave one of the fields empty and submit, a pop-up will appear saying you have to fill out the field. If you leave the field empty and submit it again the same pop-up will appear, but with the option to not show this warning again. If you check this option, press ok and submit again, you will register successfully even though the field is still empty!
Submitted byrachey (not verified)on Sun, 05/04/2014 - 18:22

hello Argie, thanks to you. succeed that I run your code. but, it appears some sentences like "Notice: Undefined index: remarks in C:\xampp\htdocs\test\index.php on line 10". what does that mean? Thank you! Have a nice day!
Submitted byhangonon Sun, 05/18/2014 - 02:30

please help me fully by explaining logout also and simply oin detail
Submitted byMuleta Alem (not verified)on Mon, 06/02/2014 - 09:58

Wow Thank You really Bless You ...!
Submitted byPrince Ogology (not verified)on Wed, 06/11/2014 - 05:56

This is what i have been searching for for long. thanks! It's so helpful
Submitted byEdward Omowa (not verified)on Wed, 06/11/2014 - 16:27

What a bug-free code! Keep it up Argie.
Submitted byromnickz (not verified)on Sat, 06/14/2014 - 09:34

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\nickz\code_exec.php:1) in C:\xampp\htdocs\nickz\code_exec.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\nickz\code_exec.php:1) in C:\xampp\htdocs\nickz\code_exec.php on line 2 Could not select database
Submitted bymarasoft (not verified)on Mon, 07/28/2014 - 19:45

in face it is the best

The requested URL /admin/admin_index.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Submitted bykaushik khandhar (not verified)on Wed, 12/17/2014 - 15:44

It's work great thanku so much
Submitted byAnonymous (not verified)on Sat, 01/24/2015 - 18:20

thanx sir i can get a knowledge
Submitted byBest King (not verified)on Wed, 04/15/2015 - 17:07

how to do that when I sign them so I threw the code_exec.php but that it held to php

Submitted byAvery T. Horton, Jr. (not verified)on Sat, 05/23/2015 - 00:46

var f=document.forms["reg"]["pic"].value; var g=document.forms["reg"]["pic"].value; var h=document.forms["reg"]["pic"].value; is in error! Should be: var f=document.forms["reg"]["pic"].value; var g=document.forms["reg"]["username"].value; var h=document.forms["reg"]["password"].value;
Submitted byjustwhatiam (not verified)on Thu, 06/04/2015 - 11:06

sorry mam ,but i really please you to rather offer a zip download of source along with the text source
Submitted byMr. Prince (not verified)on Wed, 11/18/2015 - 19:42

hi, everything is working perfectly bt i discovered that the field are interchanged in the database, i.e the position of username, password... has shifted to the position of fname, lname... respectively which apply to the rest of the field. secondly, i can view my saved information, any observation?
Submitted bykamalabe costa (not verified)on Sat, 03/12/2016 - 22:08

for real this good creating the registration form was my problem but i found the reality
Submitted bymihratu temesgen (not verified)on Mon, 04/17/2017 - 17:53

Oh you are really programmer I want to be with you to develope my profession

Add new comment