step 1:- Firstly create a database name & secondly create a table in MySQL.
step 2:-After that create a table structure eg. Column Name1 , Coulmn Name2 , Coulmn NameN...
step 2:-After that create a table structure eg. Column Name1 , Coulmn Name2 , Coulmn NameN...
<?php
mysql_connect("localhost","root","");
mysql_select_db("project");
//insert data in database using submit button request
if (isset($_REQUEST['submit']))
{
$n=$_REQUEST['name'];
$p=$_REQUEST['pass'];
$g=$_REQUEST['gender'];
$h=$_REQUEST['chk'];
if ($h)
{
$ch=implode(",",$h);//implode is a string function that are implode a multipal array value like chk[];
}
$ins="insert into user(name,pass,gender,hobby) values('$n','$p','$g','$ch')";
$ex=mysql_query($ins);
}
?>
<html>
<head>
<title>insert the data</title>
</head>
<body>
<form method="post">
<table border="1" align="center">
<tr>
<td>name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>password</td>
<td><input type="text" name="pass"></td>
</tr>
<tr>
<td>male</td>
<td><input type="radio" name="gender" value="male">male<input type="radio" name="gender" value="female">female</td>
</tr>
<tr>
<td>hobby</td>
<td><input type="checkbox" name="chk[]" value="cricket">cricket<input type="checkbox" name="chk[]" value="hockey">hockey</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</form>
</body>
</html>
0 comments:
Post a Comment