Hi all,
This has got three parts
1. Code in the form - saveform.php
<html>
<body>
<?php
include('dbconnect.php');
$mid=getid('student','sid');
?>
<form action=savestudent.php method=post>
Id <input type=text name=id1 value='<?php echo $mid; ?>' disabled >
<input type=hidden name=id value='<?php echo $mid; ?>' ><br>
Name <input type=text name=name><br>
<input type=submit value='save'>
</form>
</body>
</html>
2. Code in the save part -savestudent.php
<?php
$id=$_POST['id'];
echo $id;
include('dbconnect.php')
//DB insert query part
?>
3. Include file - dbconnect.php
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("anganwadi", $con);
function getid($tablename,$fieldid)
{
$query="select max($fieldid)+1 as mid from $tablename";
echo $query;
$data=mysql_query($query);
$maxid=0;
while($row=mysql_fetch_array($data))
{
$maxid=$row['mid'];
}
return $maxid;
}
?>