Monday, 10 August 2015

a simple code for insert data into the database.you can call it registration form.

html from

<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color: -moz-buttonhoverface;
}
.from-main{
left: 500px;
position: absolute;
top: 142px;
}
.text-box{
height: 28px;
margin: 8px;
text-align: center;
width: 257px;
}
.button{
background-color: -moz-dialog;
height: 42px;
left: 193px;
position: absolute;
width: 75px;

}
</style>
</head>
<body>
<div class="from-main">
<h2>Registor Here</h2>
<form action="insert.php" method="post"></br>
<input type="text" name="name" placeholder="name" class="text-box" required /></br>
<input type="text" name="email" placeholder="email" class="text-box" required/></br>
<input type="text" name="password" placeholder="password"class="text-box" required/></br>
<input type="submit" value="submit" class="button"/>
</form>
</div>
</body>
</html>

------------------------------------------------------php code insert.php-----------------------------------
<?php
//storing the host in $host variable & user in $ $user variable and same for the password.
$host = "localhost";
$user = "root";
$password = "";
//make the connection and store in the $conn variable.
$conn = mysql_connect($host,$user,$password);

//this is the POST value we are geeting from html page,
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
//run your queary
$sql = "insert into crud(name,email,password) values('$name', '$email', '$password')";
//select database
mysql_select_db('crud');
//execute query
mysql_query($sql,$conn);
?>