***hi to all **i need to give auto numbering in the form for different users.If one user login and insert the data ,want to get the filed number as 1 and press next button and redirect to the form filling the another data number be 2,like that..
if second user login and filling the form they need to get the form number as 1 only as per the login id and date.
my html table
<html>
<head>
<style>
.data{
background : #e0e0a0;
padding:5px;
align:center;
height:200px;
width:500px;
float:left;
margin-right:200px;
margin-left:400px;
border:1px #000000;
border-radius: 0px ;}
</style>
</head>
<script>
var i = 1;
function buttonClick() {
i++;
document.getElementById('inc').value = i;
}
</script>
<body>
<?php
if(isset($_SESSION['useremail']))
{
?>
<div class="data">
<form name="f1" method="post" action="material_action.php">
<table border="0" width="500" align="center" class="demo-table">
<tr>
<th align=center colspan=2><h1>Materials</h1></th>
</tr>
<tr>
</tr>
<tr>
<td><b>Code :</b></td><td><input type=number name="code"class="counter"id="inc" value="1" required autofocus placeholder="slno:" ></td>
</tr>
<tr>
<td><b>Materials:</b></td><td><input type=text name="material" required autofocus placeholder="16mmply"></td>
</tr>
<tr>
</tr>
<tr>
<td><b>shade:</b.</td><td><input type=text name="shade" required autofocus placeholder="bsl/osl" ></td>
</tr>
<tr>
<td><b>Grains:</b.</td><td><input type="checkbox" name="grains" value="grains"> grains<br></td>
</tr>
<tr>
</tr>
<tr>
<tr><td>
<td><td><input type=submit value="NEXT"class="increment-btn"onclick="buttonClick();" name='button'>
<input type=submit value="VIEW" name='button'>
<input type="submit" align=center name="submit" value="OK" class="btn register"><br/></td></tr>
</tr>
</form>
</table>
</div>
<?php
}
else
{
header("location:login1.php");
}
?>
</body>
</html>
> php code
<?php
session_start();
$counter=1;
if(isset($_POST)& !empty($_POST))
{
$counter++;
$sql="select custcode from users where useremail= '". $_SESSION['useremail'] ."'";
require'connect.php';
$result = mysqli_query($con,$sql);
$code=mysqli_fetch_array($result);
$company=$code['custcode'];
$count=mysqli_num_rows($result);
if($count>0)
{
$cust=$company.date(" dmy");
$_SESSION['customercode']=$cust;
}
$code=$_POST['code'];
$material=$_POST['material'];
$shade=$_POST['shade'];
$cust=$_SESSION['customercode'];
$grains=$_POST['grains'];
if($code=='')
{
header('location:./reg.php?error=Generate the code for materials!!!');
exit();
}
if (isset($_POST['grains']) && ($_POST['grains'] == "grains")) {
$grains .= "grains";
} else {
$grains .= "--";
}
$q="insert into material(code,material,shade,grains,customercode )values('$code','$material','$shade','$grains','$cust')";
require'connect.php';
$result=mysqli_query($con,$q);
if($_REQUEST['button']=="NEXT")
{
$_SESSION['Quantity']=$qnt;
header("location:material.php");
}
else
{
$errcode=mysqli_errno($con);
}
if($_REQUEST['submit']=="OK")
{
header("location:data.php");
}
else
{
echo"try again";
}
}
?>
<?php
session_start();
$counter=1;
if(isset($_POST)& !empty($_POST))
{
$counter++;
$sql="select custcode from users where useremail= '". $_SESSION['useremail'] ."'";
require'connect.php';
$result = mysqli_query($con,$sql);
$code=mysqli_fetch_array($result);
$company=$code['custcode'];
$count=mysqli_num_rows($result);
if($count>0)
{
$cust=$company.date(" dmy");
$_SESSION['customercode']=$cust;
}
$code=$_POST['code'];
$material=$_POST['material'];
$shade=$_POST['shade'];
$cust=$_SESSION['customercode'];
$grains=$_POST['grains'];
if($code=='')
{
header('location:./reg.php?error=Generate the code for materials!!!');
exit();
}
if (isset($_POST['grains']) && ($_POST['grains'] == "grains")) {
$grains .= "grains";
} else {
$grains .= "--";
}
$q="insert into material(code,material,shade,grains,customercode )values('$code','$material','$shade','$grains','$cust')";
require'connect.php';
$result=mysqli_query($con,$q);
if($_REQUEST['button']=="NEXT")
{
$_SESSION['Quantity']=$qnt;
header("location:material.php");
}
else
{
$errcode=mysqli_errno($con);
}
if($_REQUEST['submit']=="OK")
{
header("location:data.php");
}
else
{
echo"try again";
}
}
?>