Basic Registration form in PHP with MySQL database connectivity

I am glad to post here my knowledge and techniques used in PHP and MySQL. As you all aware that PHP and MySQL are the most widely used Open Source for websites. Today’s millions of websites and applications are using these free software’s. Personally I feel that this could be next level for front end developers by using PHP and MySQL a HTML developer can make a website more dynamic. Let us discuss How to create a Basic registration form in PHP with database, Its simple and very useful for a basic website dynamic user dynamic registration. Every creative can implement its basic structure to their website. Now Just follow these simple steps and you will find that your first dynamic functional registration form with database entry on every form fill up.

STEP 1: Create Database for inserting values

[divider] Go to MySQL,

Create database student;
Qurey OK, 1 row affected (0.00 sec)

mysql> use student
Database changed

mysql> create table student(id int,name varchar(40),email varchar(80),password varchar(40));

Query OK, 0 rows affected (0.05 sec)

STEP 2: Front end code, Make HTML Structure of your registration form

[divider] Make a new file registration.html we will make it in PHP later, the structure would be:

<title>REGISTRATION FORM</title>

<form name="registration" method="post" action="registration.php">
<!-- we will create registration.php after registration.html -->
USERNAME:<input type="text" name="name" value=""></br>
EMAIL-ID:<input type="text" name="email" value=""></br>
PASSWORD:<input type="text" name="password" value=""></br>
RE-PASSWORD:<input type="text" name="repassword" value=""></br>
<input type="submit" name="submit" value="submit">


STEP 3: For Database connectivity using MySQL

[divider] Create a connect.php file for basic database connection use that default code as below

$hostname="localhost"; //local server name default localhost
$username="root";  //mysql username default is root.
$password="";       //blank if no password is set for mysql.
$database="student";  //database name which you created
if(! $con)
die('Connection Failed'.mysql_error());


STEP 4: Finally create a registration.php page to get value of all fields shown in HTML page

[divider] Here a Front end developer can write some own code in PHP, Read the code and understand this basic structure line by line you will find it very easy.

<?php     //start php tag
//include connect.php page for database connection
//if submit is not blanked i.e. it is clicked.
If($_REQUEST['name']=='' || $_REQUEST['email']=='' || $_REQUEST['password']==''|| $_REQUEST['repassword']=='')
Echo "please fill the empty field.";
$sql="insert into student(name,email,password,repassword) values('".$_REQUEST['name']."', '".$_REQUEST['email']."', '".$_REQUEST['password']."', '".$_REQUEST['repassword']."')";
Echo "Record successfully inserted";
Echo "There is some problem in inserting record";




[divider] By following step by step procedure provided above a basic registration form can be created. So best of luck for your first PHP code Get the code snippets here.

By Akshma Sharma

Web & PHP Developer, with a zeal experience of web and application development on various platform like Android, iOS, PHP, MySQL, CMS, Wordpress, Joomla, Magento and Drupal.

49 replies on “Basic Registration form in PHP with MySQL database connectivity”

i am getting error in registration.php at 5th line the error is
Parse error: syntax error, unexpected T_IF in /home/a3403532/public_html/registration.php on line 5

how to clear it sir please help me out here

it keeps giving me “There is some problem in inserting record.., cant seem to find whats wrong.

why when i register , if just comeout There is some problem in inserting record ?? i ady fill in the form . pls help


@ raine ,Dhaos
Plz check your if($res) condition.Here your result may be null that’s why it is going in else part.
Check your query just simply echo $sql;
It will show what is going in your sql query.


$sql=”insert into student(name,email,password) values(‘”.$_REQUEST[‘name’].”‘, ‘”.$_REQUEST[’email’].”‘, ‘”.$_REQUEST[‘password’].”‘)”;

This is the query you have to use.


It is

Line 5 error: parse error
Parse error: syntax error, unexpected T_IF in C:\wamp\www\CARSHOPPINNG\registration.php on line 5

Hello on line 4 you have to put a semicolin after include = (‘connect.php’) “;” I put it in to qoutations and if I helped please please visit my website

i got this message help plz Parse error: syntax error, unexpected ‘742805’ (T_LNUMBER), expecting variable (T_VARIABLE) or ‘$’ in /home/vhosts/ on line 7

Please i need help , after submit this’s the msg I got Connection FailedAccess denied for user ‘apache’@’localhost’ (using password: NO)

Hi All,

@ junior
1)Please check your mysql password you are using in connect.php.The password you are using may be different from your connect.php.If you have no password for your mysql just blank for $password=””; if you have set any password then put it in quotes.Then FailedAccess denied for user ‘apache’@’localhost’ (using password: NO) will be resolved.

@Nikhil & junior

2) Parse error: syntax error, unexpected ‘If’ (T_IF) in to remove this plz use semicolon after include(“connect.php”);

This is just a validation for empty field if you are going to post an empty field.


hi. i am php beginner. i want to be a php programmer but i need help to do programming in php. anybody can help me ?
This artical really helped me more than i expect.

this warning is coming please help!
mysql_connect(): Access denied for user ‘root’@’localhost’ (using password: NO) in D:\xampp\htdocs\student\connect.php on line 6
Connection FailedAccess denied for user ‘root’@’localhost’ (using password: NO)

help help help!
it is not connecting to database. how can i see if entry of data is been done or not in to database when i registered.

great tutorial!!!!!!!!!!! can you create a log in tutorial where users can log in using their information provided in this tutorial???


I want simple file uploading code in php that can be used to uploads various type files in secure manner.

To Those who gets Error or the Display “There is some problem in inserting record”

Step1: Review your Code.
Step2: make your you have the Correct Field in the Database and Correct naming of the textbox in your HTML.

I Hope it Helps… 🙂

I’ve been browsing online more than 4 hours today, yet I never found any interesting article like yours.
It’s pretty worth enough for me. In my view, if all
web owners and bloggers made good content as you did, the net will be
a lot more useful than ever before.

please help me, when i submit it gives me an error.
( ! ) Parse error: syntax error, unexpected ‘If’ (T_IF) in C:\wamp\www\registration.php on line 5

I think that is among the so much significant information for me.
And i’m satisfied studying your article. However
want to remark on few general things, The web site
style is wonderful, the articles is in point of fact excellent
: D. Excellent process, cheers

Hey very nice blog!! Man .. Beautiful .. Amazing .. I’ll bookmark your website and take the feeds alsoI am happy to find a lot of useful info here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . . dekdecgfkkbk

Valuable information. Fortunate me I discovered your web site by chance, and I am surprised why this coincidence didn’t happened in advance! I bookmarked it. dkbegebgffddcabe

plz help me whenever i try to register it shows me “There is some problem in inserting record”..

so i edited the code to only use 2 inputs
and i did this to test the values “Echo $sql;”

but it displayed this.

There is some problem in inserting record insert into student(name,email) values(‘da’,’fa’)

useful information for beginners. it will help self learning process. I think this is best place to learn php.

Hey There. I discovered your weblog the usage of msn. That is a really neatly written article.

I will be sure to bookmark it and come back to read more of
your useful info. Thanks for the post. I will definitely comeback.

Pretty great post. I simply stumbled upon your blog and wanted to say that I have truly enjoyed browsing your
blog posts. In any case I will be subscribing for your rss feed and I am hoping you write once more

I’ve been exploring for a little bit for any high quality articles or weblog posts on this kind of house
. Exploring in Yahoo I finally stumbled upon this web site.
Reading this info So i’m glad to exhibit that I’ve a very excellent uncanny feeling I discovered just
what I needed. I such a lot for sure will make certain to
don?t overlook this web site and give it a glance regularly.

Having read this I thought it was rather informative.
I appreciate you finding the time and energy
to put this content together. I once again find myself spending way too much time both reading and leaving comments.
But so what, it was still worth it!

i have made the above mention program and form working correctly but i have problem here i want to fetch data from database.someone tell me the procedure regards…wiki

Comments are closed.