PHP: Mysql SignUp Form |simple Registration form in php :-

Techno PHP

SIGN up is a simple process of insert the values in the database.In Sign Up system you have to used insert query.

First of all, we will create a database table in which all values will be stored. Database Structure.



CREATE TABLE  `student` (

 `id` INT( 50 ) NOT NULL ,
 `name` VARCHAR( 40 ) NOT NULL ,
 `gender` VARCHAR( 30 ) NOT NULL ,
 `dob` VARCHAR( 30 ) NOT NULL ,
 `email` VARCHAR( 40 ) NOT NULL ,
 `mobile` VARCHAR( 43 ) NOT NULL ,
 `password` VARCHAR( 40 ) NOT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;


Now we create a HTML form.
Inside the HTML form , we will include some fields like -
Name
gender
Date of birth
Email
mobile
Password

Simple Registrtion form in php

<html>
<body>
<center>
<form action="" method="post"
<fieldset>
 Sign Up
Name:-


Gender :- Male Female

DOB:-

Email :-

Mobile Number :-

Password:-



</fieldset > </form> </center>

After creating HTML form , we have to need PHP code for performing the logical part. If any user fill out the complete form and then click on the Submit button, the PHP code is executed and save the form data directly into the database.

1.mysqli_connect is used to database connectivity. mysqli_connect taken four arguments.
I. your host address(localhost)
II. Server username (root)
III. password (blank if password not set)
IV. Database Name.
2. Now if the condition is used to set the values. If values are set then save in the database and if values are noted set then show the error message.
3. In the sign up you have to use insert query. Insert query is used to insert the values in the database.

PHP Script code

<?php
$cser=mysqli_connect("localhost","root","","test");
if(isset($_POST['submit']))
{
	$name = $_POST['name'];
	$gender = $_POST['ab'];
	$dob = $_POST['dob'];
	$email = $_POST['email'];
	$number = $_POST['number'];
	$password = $_POST['password'];
	$result = mysqli_query($cser,"insert into student values('','$name','$gender','$dob','$email','$number','$password')");
	if($result)
	{
		echo "Registration Successfully";
	}
	else{
		echo "failed:";
	}
}
?>

Now this time to implement. You can see the real demo by click on Run .

Final Code


<html>
<body>
<center>
<form action="" method="post"
<fieldset>
 Sign Up
Name:-


Gender :- Male Female

DOB:-

Email :-

Mobile Number :-

Password:-



</fieldset > </form> </center> <?php $cser=mysqli_connect("localhost","root","","test"); if(isset($_POST['submit'])) { $name = $_POST['name']; $gender = $_POST['ab']; $dob = $_POST['dob']; $email = $_POST['email']; $number = $_POST['number']; $password = $_POST['password']; $result = mysqli_query($cser,"insert into student values('','$name','$gender','$dob','$email','$number','$password')"); if($result) { echo "Registration Successfully"; } else{ echo "failed:"; } } ?>
Run