Simple registration form in PHP and MYSQL


In most of the websites and web portals to maintain the separate data for each user we have login system. By logging in to website we can maintain user details and also manage our account. Same time the website admin can find out visitor activity in the website.

Simple Registration Form in PHP

So in order to make this, initially we have to get some details from user. The process of getting the details from user and save it in database is called Registration. In technical terms registration is nothing but creating a unique identity for each member to maintain his data.

In this article I will explain you how to create a simple registration form using PHP and MYSQL. You can view demo and download the example file below

Download FileDemo

Create a MYSQL Database. Now we need to create a table called `registration`.

CREATE DATABASE `registration` ;

Create table in database

CREATE TABLE `registration`.`registration` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR( 25 ) NOT NULL ,
`date` VARCHAR( 20 ) NOT NULL ,
`email` VARCHAR( 25 ) NOT NULL ,
`password` VARCHAR( 20 ) NOT NULL ,
`mobile` VARCHAR( 20 ) NOT NULL ,
`IP` VARCHAR( 20 ) NOT NULL
) ENGINE = MYISAM ;

Now create the HTML form

 
Userame :
Password :
Email :
Mobile No :
 Â

Save the file as index.php in a new directory. Now we have to get the values from text box and store it in database. Find the PHP script below to insert this value to database.

Creating the data base Connection(config.php)

Inorder to insert the data to mysql database firt you need to ceate a database connection.

Save the below file as config.php

//Mysql Connect  |   mysql_connect("host","username","password");
//Below example to connect in localhost
$a=mysql_connect("localhost","root","");

//select your database
$b=mysql_select_db("database_name",$a);

$username=$_POST['username'];
$password=$_POST['password'];
$mobile=$_POST['mobile'];
$email=$_POST['email'];

//Database connection
require_once("config.php");

//mysql query to insert value to database
$query=mysql_query("INSERT INTO registration (`id`, `username`, `date`, `email`, `password`, `mobile`, `ip`) VALUES ('', '$username', '".date('d-m-Y')."', '$email', '$password', '$mobile', '".$_SERVER['REMOTE_ADDR']."')");

//if value inserted successyully disply success message
if($query)
{
	
    echo '
Registred successfully..!!
'; }else { //error message echo '
unable to registred !!
'; }

Save the file as submit-form.php and run the index.php file. Enter all the details and submit the form. When you submitting the form PHP will get values from all input fields and insert in to MYSQL database. This is the simple and easiest way of making registration form using PHP and MYSQL.

Download Registration form Script in PHP

1 Comment Simple registration form in PHP and MYSQL

  1. Anonymous

    Hi, there this is kinda of off topic but I was wondering if blogs use WYSIWYG editors, or if you have to manually code with HTML. I’m starting a blog soon but have no coding expertise so I wanted to get guidance from someone with experience. Any help would be enormously appreciated!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>