Database insertion error 04-30-2014, 10:43 AM
#1
I am trying to create a simple registration form
but when I click to submit button data isn't inserting in database.
Plz can anyone help me regarding this.
Thank you.
My registration.html file
My php file
my connect file
here is table structure
with id auto increment
![[Image: image.jpg]](http://s27.postimg.org/npumqk5mn/image.jpg)
Thank You.
but when I click to submit button data isn't inserting in database.
Plz can anyone help me regarding this.
Thank you.
My registration.html file
Code:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div>
<form action="index.php" method="post" name="reg">
<table style="width:100%">
<tr><td style="30%"> Name:</td>
<td style="70%"><input type="text" name="name"></td>
</tr>
<tr><td style="30%">Email:</td>
<td style="70%"><input type="text" name="mail"></td>
</tr><tr><td style="30%">Password:</td>
<td style="70%"><input type="text" name="pass"></td>
</tr><tr><td style="30%"></td>
<td style="70%"><input type="submit" value="submit"></td>
</tr>
</table>
</form>
</div>
</body>
</html>My php file
Code:
<?php
Include ('connect.php');
if(isset($_POST['submit'])!="")
{
if($_POST['name']==''|| $_POST['email']==''||$_POST['pass']=='')
{
echo "Please fill the following";
}
else {
$sql="insert into student(name,email,pass) values('".$_POST['name']."','".$_POST['email']."','".$_POST['pass']."')";
$res=mysql_query($sql);
if($res)
{
echo "values inserted";
}
else {
echo "insertion error";
}
}
mysql_close("db");
}
?>my connect file
Code:
<?php
$host="localhost";
$user="dave";
$pass="pass";
mysql_connect($host,$user,$pass);
mysql_select_db("db");
?>here is table structure
with id auto increment
![[Image: image.jpg]](http://s27.postimg.org/npumqk5mn/image.jpg)
Thank You.


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)


![[Image: wvBFmA5.png]](http://i.imgur.com/wvBFmA5.png)