Thursday, 18 April 2013

Create New User Registration using PHP + MySQL Database connectivity


Write Insert Query to perform insert operation.

Direct Record fill by user itself <?php

// Create connection
$con=mysqli_connect(@"localhost","root","","Database1");


//Insert into table data
mysqli_query($con,"INSERT INTO tbladmin VALUES ('hitesh','hitesh','kumar','hiteshvataliya1@gmail.com','12391239123')");



?> 

By using Form user defined insert page


<html>
<head><title>Insert into Database</title>
<?php
if(isset($_POST['Submit'])){
$username=trim($_POST['username']);
$password=trim($_POST['password']);
$name=trim($_POST['name']);
$number=trim($_POST['number']);
$email=trim($_POST['email']);

// Create connection
$con=mysqli_connect(@"localhost","root","","Database1");


//Insert into table data
$sql="INSERT INTO `database1`.`tbladmin` (`username`, `password`, `fullname`, `emailid`, `mobileno`) VALUES ('$username', '$password', '$name', '$email', '$number');";

if (mysqli_query($con,$sql))
{
echo "Success";
//final code will execute here.
}
}

?> 

</head>
<body>
<form name= "info" id= "info" method= "post" action= "" >
<table width= "327" border= "0" align="center" cellpadding= "5" cellspacing= "1">

<tr>
<td>Username: </td>
<td><input name= "username" type= "text" id= "username" value="" ></td>
</tr>
<tr>
<td>Password: </td>
<td><input name= "password" type= "text" id= "password" value=""  ></td>
</tr>
<tr>
<td width= "82" >FullName: </td>
<td width= "238" ><input name= "name" type= "text" id="name" value="" ></td>
</tr>
<tr>
<td> Email: </td>
<td><input name= "email" type= "text" id= "email" value="" ></td>
</tr>
<tr>
<td>Number: </td>
<td><input name= "number" type= "text" id= "number" value="" ></td>
</tr>
<tr>
<td></td>
<td><input type= "submit" name= "Submit" value= "Submit" /></td>
</tr>
</table>
</form>
</body>
</html>

For learning PHP project - visit website www.vataliyatuitionclasses.com


No comments:

Post a Comment