<?php
$con = mysqli_connect("localhost","root","","Assignment");
if (mysqli_connect_error()) // if not connected
{
echo "Cannot connect to database";
}
else
{
$first=$_POST["fname"];
$last=$_POST["lname"];
$subj=$_POST["subject"];
$gender=$_POST["gender"];
$lang=$_POST["lang"];
$q=mysqli_query($con,"INSERT INTO student(Fname,Lname,Subject,Gender,language) VALUES('$first','$last','$subj','$gender','$lang')");
if(!$q)
{
echo "insertion failed....";
}
else
{
?>
<script>
var conf = confirm("successfully data inserted....");
if(conf)
window.location="index.html";
</script>
<?php
mysqli_close($con);
}
}
?>
$con = mysqli_connect("localhost","root","","Assignment");
if (mysqli_connect_error()) // if not connected
{
echo "Cannot connect to database";
}
else
{
$first=$_POST["fname"];
$last=$_POST["lname"];
$subj=$_POST["subject"];
$gender=$_POST["gender"];
$lang=$_POST["lang"];
$q=mysqli_query($con,"INSERT INTO student(Fname,Lname,Subject,Gender,language) VALUES('$first','$last','$subj','$gender','$lang')");
if(!$q)
{
echo "insertion failed....";
}
else
{
?>
<script>
var conf = confirm("successfully data inserted....");
if(conf)
window.location="index.html";
</script>
<?php
mysqli_close($con);
}
}
?>
No comments:
Post a Comment