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 byAnonymous (not verified)on Wed, 04/24/2013 - 09:14

is it possible to sent registration information to a e-mail
Submitted byAnonymous (not verified)on Fri, 04/26/2013 - 17:48

javascript validation are not very safe and javascript can be disabled from the client pc so... validations can be bypassed
Submitted byAnonymous (not verified)on Thu, 05/02/2013 - 13:24

Notice: Undefined index: remarks in C:\xampp\htdocs\index.php i got a error on remarks in index.php
Submitted byAnonymous (not verified)on Sat, 05/04/2013 - 00:19

I m not able to insert values into database :(( wat to do???
Submitted byAnonymous (not verified)on Sat, 05/18/2013 - 19:40

this is a marvelous!!
Submitted byAnonymous (not verified)on Mon, 05/20/2013 - 06:30

Thank you very much for the explanation! :)
Submitted byAnonymous (not verified)on Tue, 05/21/2013 - 14:07

i am unable to connect database showing error----"Could not select database"
Submitted byAnonymous (not verified)on Fri, 05/24/2013 - 16:26

Hi, I don't know who write this script but awesome, Thanks a lot for sharing this online..
Submitted byAnonymous (not verified)on Wed, 06/12/2013 - 00:44

Thank u so much
Submitted byAnonymous (not verified)on Wed, 06/12/2013 - 01:03

I GOT AN ERROR REMARKS IS AN UNDEFINED INDEX WHEN EXECUTING INDEX.PHP
Submitted byAnonymous (not verified)on Fri, 06/14/2013 - 16:57

Absolutely dreadful tutorial. Uses deprecated APIs, and is littered with bad practice and novice errors.
Submitted byAnonymous (not verified)on Mon, 06/17/2013 - 15:18

thanks friends this is very useful validation example for beginners. i request you for post more this types of help code thanks again ajay gadhavana 9033516452
Submitted byAnonymous (not verified)on Sun, 07/07/2013 - 22:17

Nice job; it rocks fine. But not really detail; fields like select box/option box and picture uploading are missing.
Submitted byAnonymous (not verified)on Mon, 07/15/2013 - 13:09

how can i insert an image into this this registration form?plz help
Submitted byCharles Gray (not verified)on Fri, 07/26/2013 - 12:50

Nice work, I used it to implement into a database I had set up with logon already. I got errors for the if ($remarks==null and $remarks=="") line and found that the and needs to be changed to or. if ($remarks==null or $remarks=="") $remarks can't have two values at once so that if statement will never run.
Submitted byKanyingi (not verified)on Wed, 08/21/2013 - 18:08

For those getting the 'remarks' error, this fix worked for me.
  1. <?php
  2. if (!isset($_GET['remarks']))
  3. {
  4. $remarks="";
  5. }
  6. if (isset($_GET['remarks']))
  7. {
  8.  
  9. if($_GET['remarks']=='success')
  10. {
  11. echo '<p align="center">The registration process was a success. Please proceed by Logging in, thank you! <hr /></p>';
  12. }
  13. }
  14. ?>
Submitted bypanee (not verified)on Mon, 05/12/2014 - 19:06

In reply to by Kanyingi (not verified)

Okay this worked perfectly for me, but it appears on top of the registration form (in other words, the registration form does not disappear when you submit the information details..They're still visible on the page..) So, how do I get to make the registration form no longer visible, and only the message "The registration process was a success. Please proceed by Logging in, thank you!" appear on the page? Please help shed some light on this matter, thanks in advance!
Submitted byShanti (not verified)on Sat, 08/24/2013 - 14:06

Hai, how to check the duplicate username already entered in the database.

Submitted bytarun (not verified)on Sun, 08/25/2013 - 12:41

where we add java script index.php page in a head tag its show the error
Submitted bytsegay(from Et… (not verified)on Fri, 09/06/2013 - 16:49

I see your code it so much good but I want to say that if you can please do it edit in some points and do for other language also by thanks!!
Submitted bySujal (not verified)on Sun, 10/06/2013 - 01:31

Hey can you help me out??!! What is prefix and what do i enter there and also i get error "Could not select database"??
Submitted byDebi Ogunli (not verified)on Wed, 10/09/2013 - 05:35

THANK YOU VERY MUCH, MAY GOD RICHLY BLESS YOU. I AM BEEN SEARCHING ONLINE FOR A LONG TIME BUT NO AVAIL NOT UNTILL TODAY I CAME ACROSS YOUR POST, VERY PRECISE AND ACURATE. PLEASE CAN U HELP ME WITH SIGIN IN PAGE AGAIST THE REGISTRATION PAGE. THANK YOU.
Submitted bybhimaram (not verified)on Sun, 10/20/2013 - 15:24

thanks my data store in database thanks so much
Submitted byradha krishna (not verified)on Fri, 11/22/2013 - 21:20

i have a little bit confusion...where is the location we retreive the remarks....i mean $_GET['remarks'].....what it means.....plz clear my doubt...and thanks for code.....
Submitted bypathakaramuthu (not verified)on Mon, 11/25/2013 - 16:10

it is very useful for my project
Submitted byPradeep_kolkata (not verified)on Thu, 12/05/2013 - 16:09

Its really helpful , Thanks alot.
Submitted byadebanjo (not verified)on Sun, 12/15/2013 - 00:25

the post is fantastic
Submitted byMonty R Ferbert (not verified)on Sun, 12/22/2013 - 03:59

how come on the more secure Login Page using the Md5 code even with a proper connection to the data base the darn login page can't find the username and password. I've double and triple checked everything I can't solve the problem.
Submitted bySushil Thorkar (not verified)on Wed, 01/08/2014 - 02:09

Its really better for new guyes to put their efforts in coding.
Submitted byfuck me (not verified)on Tue, 01/14/2014 - 02:04

i am getting an error Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /home3/grabucom/public_html/connection.php on line 7 Could not connect database help me man
Submitted by-here- (not verified)on Tue, 02/11/2014 - 08:47

there is no need to validate all the fields once then start checking the value of each single text boxes. Where your first checking result will be true the rest of course will be true too
Submitted byJamiezszcdasd (not verified)on Wed, 02/12/2014 - 21:36

Hi there can you someone please help me on the validation part of this code, I keep trying to get to add the validation in to my index.php but it keeps failing to work. Where exactly do insert it because i tried head tags and does not work.
Submitted bylr (not verified)on Fri, 02/14/2014 - 14:00

how cn i make the code if i will going to load the form in listview the ID will be show
Submitted byMeer@ (not verified)on Fri, 02/14/2014 - 18:42

your code is useful in our study so thanks again
Submitted byAnonymous (not verified)on Sun, 03/02/2014 - 12:02

Good Code. Works Perfectly.
Submitted byTstatke (not verified)on Mon, 03/03/2014 - 16:33

thanks for the code for this. Its much help.

Add new comment