database name:student tablename:stud fields : name, email, gender
<form name = "frm1" action="#" method="post">
enter name : <input type="text" name="sname"><br>
enter email : <input type="text" name="email"><br>
enter gender :<input type="radio" name="sex" value="m">male <input type="radio" name="sex" value="f">female<br>
<input type="submit" name="submit" value="insert">
</form>
<?php
if(isset($_POST["submit"]))
{
$link=mysql_connect("localhost","root","");
mysql_select_db("student");
$name=$_POST["sname"];
$email=$_POST["email"];
$gender=$_POST["sex"];
$sql="insert into stud(name,email,gender) values('$name','$email','$sex')";
$res=mysql_query($sql);
if($res)
{
echo "<font color='green'>record inserted successfully";
}
else
{
echo "<font color='red'>Record not Inserted....";
}
}
//print_r($_POST);
?>
No comments:
Post a Comment