I have a roles called read,write,and delete operation for a list of menu.I am listing menu with read,write,delete operation with a checkbox to insert to database but when i try to insert its not inserting multiple its inserting has one row in mysql here my code
database
Code
Form.php
<form method="post" action="insertuser.php" class="form-horizontal">
<fieldset>
<div class="form-group">
<label class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="username" id="username" required>
<span class="help-block">Please Enter Username</span>
<span class="help-block" id="name_status"></span>
</div>
</div>
</fieldset>
<fieldset>
<div class="form-group">
<label class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" name="password" id="password" required>
<span class="help-block">Please Enter Password</span>
</div>
</div>
</fieldset>
<fieldset>
<div class="form-group">
<label class="col-sm-2 control-label">Email Address</label>
<div class="col-sm-10">
<input type="email" class="form-control" name="emailaddress" id="emailaddress" required>
<span class="help-block">Please Enter Email Address</span>
<span class="help-block" id="name_status1"></span>
</div>
</div>
</fieldset>
<fieldset>
<div class="form-group">
<label class="col-sm-2 control-label">Role Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="rolename" id="rolename" required>
<span class="help-block">Please Enter Role Name</span>
<span class="help-block" id="name_status2"></span>
</div>
</div>
</fieldset>
<table id="example" class="table table-striped table-bordered" >
<thead>
<th data-field="id" data-sortable="true">Menu Name</th>
<th data-field="name" data-sortable="true">Read</th>
<th data-field="actions" data-sortable="true">Edit</th>
<th data-field="actions" data-sortable="true">Delete</th>
</thead>
<tbody>
<?php
$i=0;
$selectquery=mysql_query("select * from menumanagement");
while($row=mysql_fetch_array($selectquery))
{
?>
<tr>
<td><?php echo $row["mn_menuname"]; ?></td>
<td>
<label class="checkbox checkbox-inline checked">
<span class="icons"><span class="first-icon fa fa-square-o"></span><span class="second-icon fa fa-check-square-o"></span></span><input type="checkbox" name="read1[]" id="read1" value="1_<?php echo $row["mn_id"]; ?>">
</label>
</td>
<td>
<label class="checkbox checkbox-inline checked">
<span class="icons"><span class="first-icon fa fa-square-o"></span><span class="second-icon fa fa-check-square-o"></span></span><input type="checkbox" name="edit1[]" id="edit1" value="1_<?php echo $i."_".$row["mn_id"]; ?>">
</label>
</td>
<td>
<label class="checkbox checkbox-inline checked">
<span class="icons"><span class="first-icon fa fa-square-o"></span><span class="second-icon fa fa-check-square-o"></span></span><input type="checkbox" name="delete1[]" id="delete1" value="1_<?php echo $i."_".$row["mn_id"]; ?>">
</label>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<center><button type="submit" class="btn btn-fill btn-warning btn-wd" id="addmenu">Add User</button></center>
</div>
</form>
Insert.php
<?php
include_once("includes/db.php");
if(!empty($_POST["username"]))
{
$username=$_POST["username"];
}
if(!empty($_POST["password"]))
{
$password=$_POST["password"];
}
if(!empty($_POST["emailaddress"]))
{
$emailaddress=$_POST["emailaddress"];
}
$insertquery=mysql_query("insert into useraccess(useraccess_username,useraccess_password,useraccess_emailaddress) values ('$username','$password','$emailaddress')");
$userid=mysql_insert_id();
if($insertquery)
{
if(empty($_POST["read1"]))
{
$readid=0;
}
if(empty($_POST["edit1"]))
{
$editid=0;
}
if(empty($_POST["delete1"]))
{
$deleteid=0;
}
if($_POST["read1"])
{
$readid="";
$menuid="";
$countread=count($_POST["read1"]);
for($i=0;$i<$countread;$i++)
{
$read1=$_POST["read1"][$i];
$readdiv =explode("_", $read1);
$readid .=$readdiv[0];
$menuid .=$readdiv[1];
}
}
if($_POST["edit1"])
{
$editid="";
$menuid="";
$countedit=count($_POST["edit1"]);
for($i=0;$i<$countedit;$i++)
{
$edit1=$_POST["edit1"][$i];
$editdiv=explode("_", $edit1);
$editid .=$editdiv[0];
$menuid .=$editdiv[1];
}
}
if($_POST["delete1"])
{
$deleteid="";
$menuid="";
$countdelete=count($_POST["delete1"]);
for($i=0;$i<$countdelete;$i++)
{
$delete1=$_POST["delete1"][$i];
$deletediv=explode("_", $delete1);
$deleteid .=$deletediv[0];
$menuid .=$deletediv[1];
}
}
$insertquery1=mysql_query("insert into rolemanagement(menuid,role_read,role_write,role_delete,userid) value ('$menuid','$readid','$editid','$deleteid','$userid')");
if($insertquery1)
{
header('Location: adduser.php?status="Role has been added"');
}
}
?>
Regards
Related
Using php, I want to make the Edit button in register.php to display the form which shows fields that have the already existing user's data and then admin can update the data. I'm about to go crazy because of this thing it's been the third day in row not moving to the second step! I've watched many YT tutorials and explored many solutions here and in google as well, but couldn't actually figure out how to fix mine! Please if you know where my mistake is and what should I edit, do tell me and I will be more than happy to fix it.
These are my files:
register.php
<?php
session_start();
include('includes/header.php');
include('includes/navbar.php');
?>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addadminprofile">
Add Admin Profile
</button>
<!-- Modal -->
<div class="modal fade" id="addadminprofile" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Admin Data</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form action="code.php" method="POST">
<div class="modal-body">
<div class="form-group">
<label>Username </label>
<input type="text" name="username" class="form-control" required>
</div>
<div class="form-group">
<label>Full name </label>
<input type="text" name="full_name" class="form-control" required>
</div>
<div class="form-group">
<label>Email </label>
<input type="email" name="email" class="form-control" required>
</div>
<div class="form-group">
<label>Password </label>
<input type="password" name="password" class="form-control" required>
</div>
<div class="form-group">
<label>Confirm password </label>
<input type="password" name="cpassword" class="form-control" required>
</div>
<div class="form-group">
<label>Gender </label>
<input type="radio" name="gender" tabindex="1" value="Male">
<span> Male</span>
<input type="radio" name="gender" tabindex="2" value="Female">
<span> Female</span>
</div>
<div class="form-group">
<label>Age </label>
<input type="text" name="age" class="form-control" required>
</div>
<div class="form-group">
<label>Phone number </label>
<input type="text" name="phone_number" class="form-control" required>
</div>
<div class="form-group">
<label>Work durationr </label>
<input type="text" name="work_duration" class="form-control" required>
</div>
<div class="form-group">
<label >Food Category:</label>
<select name="food_category" class="form-control" required>
<option value="hot_cold_dishes">Hot/Cold Dishes</option>
<option value="desserts">Desserts</option>
<option value="drinks">Drinks</option>
</select>
</div>
<div class="form-group">
<label>IG Account </label>
<input type="text" name="ig_account" class="form-control" required>
</div>
<div class="form-group">
<label >State:</label>
<select name="state" class="form-control" required>
<option value="1">First</option>
<option value="2">Second</option>
<option value="3n">Third</option>
</select>
</div>
<div class="form-group">
<label>Postcode </label>
<input type="text" name="postcode" class="form-control" required>
</div>
<div class="form-group">
<label>City </label>
<input type="text" name="city" class="form-control" required>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="Submit" name="submit" class="btn btn-primary">Register</button>
</div>
</form>
</div>
</div>
</div>
<?php
/*
if(isset($_SESSION['success']) && $_SESSION['success'] != ''){
echo '<h2>'.$_SESSION['success'].'</h2>';
unset ($_SESSION['success']);
}
if(isset($_SESSION['status']) && $_SESSION['status'] != ''){
echo '<script>alert('.$_SESSION['status'].')</script>';
unset ($_SESSION['status']);
}
*/
?>
<div class="card shadow">
<div class="card-body">
<div class="table-responsive">
<?php
$connection = mysqli_connect("localhost", "root", "", "finalproject") or die ("<script>alert('Connection Failed.')</script>");
$sql = "SELECT * FROM users";
$result = mysqli_query($connection, $sql);
?>
<table class="table table-borderd" id="dataTable" width="30%" cellspecing="0">
<thead>
<tr>
<th>Username</th>
<th>Full Name</th>
<th>Email</th>
<th>Password</th>
<th>Age</th>
<th>Gender</th>
<th>Phone Number</th>
<th>Work Duration</th>
<th>Food Category</th>
<th>IG Account</th>
<th>State</th>
<th>Postcode</th>
<th>City</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result)){
?>
<tr>
<td><?php echo $row['username']?></td>
<td><?php echo $row['full_name']?></td>
<td><?php echo $row['email']?></td>
<td><?php echo $row['password']?></td>
<td><?php echo $row['phone_number']?></td>
<td><?php echo $row['work_duration']?></td>
<td><?php echo $row['food_category']?></td>
<td><?php echo $row['ig_account']?></td>
<td><?php echo $row['state']?></td>
<td><?php echo $row['postcode']?></td>
<td><?php echo $row['city']?></td>
<td><?php echo $row['gender']?></td>
<td><?php echo $row['age']?></td>
<td>
<form action="first_register.php" method="POST">
<input type="hidden" name="edit_username" value="<?php echo $row['username'];?>">
<button type="submit" name="edit_button" class="btn btn-success">Edit</button>
</form>
</td>
<td>
<button type="submit" class="btn btn-danger">Delete</button>
</td>
</tr>
<?php
}
}
else{
echo "No record found";
}
?>
</tbody>
</table>
</div>
</div>
<?php
include('includes/script.php');
include('includes/footer.php');
?>
first_register.php
<?php
$connection = mysqli_connect("localhost", "root", "", "finalproject")or die ("<script>alert('Connection Failed.')</script>");
session_start();
include('includes/header.php');
include('includes/navbar.php');
?>
<div class="container-fluid">
<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary"> EDIT Admin Profile </h6>
</div>
<div class="card-body">
<?php
if(isset($_POST['edit_button']))
{
$username = $_POST['username'];
$query = "SELECT * FROM register WHERE username='$username' ";
$query_run = mysqli_query($connection, $query);
foreach($query_run as $row)
{
?>
<form action="code.php" method="POST">
<input type="hidden" name="edit_username" value="<?php echo $row['username'] ?>">
<div class="form-group">
<label> Full name </label>
<input type="text" name="edit_full_name" value="<?php echo $row['full_name'] ?>" class="form-control">
</div>
<div class="form-group">
<label>Email</label>
<input type="email" name="edit_email" value="<?php echo $row['email'] ?>" class="form-control"
placeholder="Enter Email">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="edit_password" value="<?php echo $row['password'] ?>"
class="form-control" placeholder="Enter Password">
</div>
<div class="form-group">
<label>Gender</label>
<input type="radio" name="edit_gender" value="Male" class="form-control">
<span> Male</span>
<input type="radio" name="edit_gender" value="Female" class="form-control">
<span> Female</span>
</div>
<div class="form-group">
<label>Age</label>
<input type="text" name="edit_age" value="<?php echo $row['age'] ?>"
class="form-control">
</div>
<div class="form-group">
<label>Phone Number</label>
<input type="text" name="edit_phone_number" value="<?php echo $row['phone_number'] ?>"
class="form-control">
</div>
<div class="form-group">
<label>Work Duration</label>
<input type="text" name="edit_work_duration" value="<?php echo $row['work_duration'] ?>"
class="form-control">
</div>
<div class="form-group">
<label>Food Category</label>
<select name="food_category" class="form-control" required>
<option value="hot_cold_dishes">Hot/Cold Dishes</option>
<option value="desserts">Desserts</option>
<option value="drinks">Drinks</option>
</select>
</div>
</div>
<div class="form-group">
<label>IG Account</label>
<input type="text" name="edit_ig_account" value="<?php echo $row['ig_account'] ?>"
class="form-control">
</div>
<div class="form-group">
<label>State</label>
<select name="state" class="form-control" required>
<option value="1">First</option>
<option value="2">Second</option>
<option value="3n">Third</option>
</select>
</div>
<div class="form-group">
<label>Postcode</label>
<input type="text" name="edit_postcode" value="<?php echo $row['postcode'] ?>"
class="form-control">
</div>
<div class="form-group">
<label>City</label>
<input type="text" name="edit_city" value="<?php echo $row['city'] ?>"
class="form-control">
</div>
<form action="edit_register.php" method="POST">
<input type="hidden" name="edit_username" value="<?php echo $row['username'];?>">
<button type="submit" name="edit_button" class="btn btn-success">Edit</button>
</form>
</form>
<?php
}
}
?>
<?php
include('includes/script.php');
include('includes/footer.php');
?>
edit_register.php
<?php
$connection = mysqli_connect("localhost", "root", "", "finalproject")or die ("<script>alert('Connection Failed.')</script>");
session_start();
include('includes/header.php');
include('includes/navbar.php');
?>
<div class="card shadow">
<div class="card-header">
<h6 class="font-weight-bold text-primary">EDIT Profile </h6>
</div>
<div class="card_body">
<?php
if(isset($_POST['updatebtn']))
{
$username2 = $_POST['edit_username'];
$full_name2 = $_POST['edit_full_name'];
$email2 = $_POST['edit_email'];
$password2 = $_POST['edit_password'];
$cpassword2 = $_POST['cpassword'];
$phone_number2 = $_POST['edit_phone_number'];
$work_duration2 = $_POST['edit_work_duration'];
$food_category2 = $_POST['edit_food_category'];
$ig_account2 = $_POST['edit_ig_account'];
$state2 = $_POST["edit_state"];
$postcode2 = $_POST['edit_postcode'];
$city2 = $_POST['edit_city'];
$gender2 = $_POST['edit_gender'];
$age2 = $_POST['edit_age'];
$query = "UPDATE users SET username='$username2', full_name='$full_name2', email='$email2', password='$password2', phone_number='$phone_number2', word_duration='$work_duration2', food_category='$food_category2',
ig_account='$ig_account2', state='$state2', postcode='$postcode2', city='$city2', gender='$gender2', age='$age2' WHERE username='$username2'";
$query_run = mysqli_query($connection, $query);
if($query_run)
{
$_SESSION['status'] = "Your Data is Updated";
$_SESSION['status_code'] = "success";
header('Location: register.php');
}
else
{
$_SESSION['status'] = "Your Data is NOT Updated";
$_SESSION['status_code'] = "error";
header('Location: register.php');
}
?>
<?php
}
?>
</div>
<?php
include('includes/script.php');
include('includes/footer.php');
?>
At register.php, you have this line this -
<input type="hidden" name="edit_username" value="<?php echo $row['username'];?>">
So at first_register.php, you should have this line like this instead -
$username = $_POST['username']; to $username = $_POST['edit_username'];
and this line like this instead -
<form action="code.php" method="POST"> to <form action="edit_register.php" method="POST">
i could see you have a form inside a another form like this
<form action="edit_register.php" method="POST">
<input type="hidden" name="edit_username" value="<?php echo $row['username'];?>">
<button type="submit" name="edit_button" class="btn btn-success">Edit</button>
</form>
//remove the form tag to this only since you have input for edit_username aready at the top of your form
<button type="submit" name="edit_button" class="btn btn-success">Edit</button>
//and finally at edit_register.php change
if(isset($_POST['updatebtn']))
to if(isset($_POST['edit_button']))
I guess this should help achieve the goal. good luck
i am creating a registration page and I want to autofill the the value of certain input field whenever i choose a specific department like .when i choose the department A . it will autofill who is the supervisor on that department on my registration .how do i do it ?
this is my html view code
<?php if (validation_errors()) { ?>
<div class="alert alert-danger" role="alert">
<center><span class="glyphicon glyphicon-alert" aria-hidden="true"></span><strong> Error!</strong><p><?= validation_errors(); } ?></p></center>
</div>
<?php if (isset($error)){ ?>
<div class="alert alert-danger" role="alert">
<center><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><strong> Error! </strong><?= $error ?> </center>
</div>
<?php } ?>
<div class="container-fluid">
<center> <h2>Register</h2></center>
<hr class="colorgraph">
<form class="form-horizontal" action="<?= base_url().'login/registeruser' ?>" method="post">
<div class="form-group">
<label for="username" class="col-sm-2 control-label "><?php if(form_error('username')){ echo '<p style="color:#a94442"> * Username </p>';} else { echo 'Username'; } ?></label>
<div class="col-sm-6">
<input type="text" class="form-control <?php if (form_error('username')) { echo
'alert alert-danger'.'"style="color:#000000'; } ?>" id="username" name="username" placeholder="Username" value="<?php echo set_value('username'); ?>">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label "><?php if(form_error('password')||form_error('confpassword')){ echo '<p style="color:#a94442"> * Password </p>';} else { echo 'Password'; } ?></label>
<div class="col-sm-6">
<input type="password" class="form-control <?php if (form_error('password')||form_error('confpassword')) { echo
'alert alert-danger'.'"style="color:#000000'; } ?>" id="password" name="password" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="confpassword" class="col-sm-2 control-label"><?php if(form_error('password')||form_error('confpassword')){ echo '<p style="color:#a94442"> * Confirm Password </p>';} else { echo 'Confirm Password'; } ?></label>
<div class="col-sm-6">
<input type="password" class="form-control <?php if (form_error('password')||form_error('confpassword')) { echo
'alert alert-danger'.'"style="color:#000000'; } ?>" id="confpassword" name="confpassword" placeholder="Confirm Password">
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label "><?php if(form_error('email')){
echo '<p style="color:#a94442"> * Email </p>';} else { echo 'Email'; } ?></label>
<div class="col-sm-6">
<input type="email" class="form-control <?php if (form_error('email')) { echo
'alert alert-danger'.'"style="color:#000000'; } ?>" id="email" name="email" placeholder="Email"
value="<?php echo set_value('email'); ?>">
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label"><?php if(form_error('fname')||form_error('mname')||form_error('lname')){ echo '<p style="color:#a94442"> * Full Name </p>';} else { echo 'Full Name'; } ?></label>
<div class="col-sm-2">
<input type="text" class="form-control <?php if (form_error('fname')) { echo
'alert alert-danger'.'"style="color:#000000'; } ?>" id="fname" name="fname" placeholder="First Name" value="<?php echo set_value('fname'); ?>">
</div>
<div class="col-sm-2">
<input type="text" value ="sa" class="form-control <?php if (form_error('mname')) { echo
'alert alert-danger'.'"style="color:#000000'; } ?>" id="mname" name="mname" placeholder="Middle Name" value="<?php echo set_value('mname'); ?>">
</div>
<div class="col-sm-2">
<input type="text" class="form-control <?php if (form_error('lname')) { echo
'alert alert-danger'.'"style="color:#000000'; } ?>" id="lname" name="lname" placeholder="Last Name" value="<?php echo set_value('lname'); ?>">
</div>
</div>
<div class="form-group">
<label for="gender" class="col-sm-2 control-label ">Gender</label>
<label class="radio-inline col-sm-1 control-label">
<input type="radio" name="gender" id="gender" value="M" selected="selected"> Male
</label>
<label class="radio-inline">
<input type="radio" name="gender" id="gender" value="F"> Female
</label>
</div>
<div class="form-group">
<label for="gender" class="col-sm-2 control-label ">Department</label>
<select name="Department">
<option value="stem">STEM</option>
<option value="gas">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
</div>
<div class="form-group">
<div class="col-sm-4 control-label">
<h3><strong>
Captcha
<?=$image; ?></strong></h3>
<input type="text" id="captcha" name="captcha" height="50px" autocomplete="off" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span> Back</button>
<button type="submit" class="btn btn-primary">Register</button>
</div>
</div>
</form>
</div>
</body>
i want to specifically use php code .how do i do it ? thanks
You can use jquery ajax functionality for the same.
My view is like i want to show the selected textbox price and code to the controller
how can i do this
<div>
<!--second line start-->
<?php
foreach ($enq_info as $ei) {
echo form_open_multipart("Quotation/prepareQuote2/$ei->eid");
if (!empty($quote_data)) {
?>
<input name="quote_check" value="1" type="text" class="form-control">
<?php
} else {
?>
<input name="quote_check" value="no" type="text" class="form-control">
<?php
}
?>
<div class="form-group">
<div class="col-sm-2">
<label for="firstname">Enquiry Id</label>
<input name="e_id" id="e_id" value="<?php echo $ei->eid;?>" type="text" class="form-control">
</div>
<div class="col-sm-3">
<label for="lastname">Company Name</label>
<input type="text" name="company_name" id="company_name" value="<?php echo $ei->company_name;?>" class="form-control" />
</div>
<div class="col-sm-3">
<label for="lastname">Contact Person</label>
<input type="text" name="c_person" id="c_person" value="<?php echo $ei->c_person;?>" class="form-control"/>
</div>
<div class="col-sm-4">
<label>Address</label>
<textarea class="form-control" id="address" name="address" value="<?php echo $ei->address;?>"><?php echo $ei->address;?></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-3">
<label for="firstname">Attn Department</label>
<textarea class="form-control" id="dept" name="dept" value="">
<?php
echo $ei->c_person." Tel ";
if(empty($ei->p_contact))
echo $ei->c_contact;
else
echo $ei->p_contact;
?>
</textarea>
</div>
<div class="col-sm-3">
<label for="lastname">Quotation For</label>
<select id="quotation_type" name="quotation_type" class="form-control m-b">
<option value="Q_Manager">Q-Manager Quote</option>
<option value="Q_Master">Q-Master Quote</option>
<option value="Q_Manager_repair">Q-Manager Repair Quote</option>
</select>
</div>
<div class="col-sm-3">
<label for="lastname">Discount</label>
<textarea class="form-control" id="discount" name="discount"></textarea>
</div>
<div class="col-sm-3">
<label for="lastname"></label><br><br>
<input type="submit" class="btn btn-success" id="default_quote" value="Generate Default Quote" onClick="rerurn disable1();"/>
</div>
</div>
<div id="showquote">
<div class="row">
<div class="hpanel">
<div class="panel-body">
<div class="col-md-12">
<table class="table table-bordered table-striped">
<tr>
<td>Product Name</td>
<td>Product Code</td>
<td>Price</td>
<td>Action</td>
</tr>
<?php
// print_r($quote_data);
foreach ($product_data as $qd) {
?>
<tr>
<td><?php echo $qd->cp_name;?></td>
<td><?php echo $qd->cp_code;?></td>
<td>
<input type="text" name="product_price[]" value="<?php echo $qd->p_price;?>">
</td>
<td>
<input type="checkbox" name="product_name[]" value="<?php echo $qd->cp_name;?>" checked/>
</td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
<?php echo form_close(); ?>
<br><br>
<!--for new manual quote-->
<?php
}
?>
<!--third line start-->
how can i send the selected values price and also product code to the controller
just add the product code - product price with comma seperated in a hidden field like below
12-20000,13-30000,14-200 and so on
and once received in controller process it with explode or other way.
hopes you understood.
Hi everyone so I have 3 tables: invoices, customers and invoice items however it does not seem to be grabbing my data, anyone have any ideas on it?
string(216) "SELECT * FROM invoices as i JOIN customers as c ON c.invoice = i.invoice JOIN invoice_items as p ON p.invoice = i.invoice WHERE i.invoice = 1000 ORDER BY i.invoice " NULL Errormessage:
From:
var_dump($query);
var_dump($resutls);
printf("Errormessage: %s\n", $mysqli->error);
QUERY:
SELECT *
FROM invoices as i
JOIN customers as c ON c.invoice = i.invoice
JOIN invoice_items as p ON p.invoice = i.invoice
WHERE i.invoice = ".$getID."
ORDER BY i.invoice
PHP
<?php
include('includes/config.php');
include('header.php');
include('functions.php');
$getID = $_GET['id'];
// Connect to the database
$mysqli = new mysqli(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME);
// output any connection error
if ($mysqli->connect_error) {
die('Error : ('.$mysqli->connect_errno .') '. $mysqli->connect_error);
}
// the query
$query = "SELECT *
FROM invoices i,customers c,invoice_items p where
c.invoice = i.invoice and p.invoice = i.invoice and
i.invoice = '".$getID."' ORDER BY i.invoice";
// mysqli select query
$results = $mysqli->query($query);
// mysqli select query
if($results) {
while($row = $results->fetch_assoc()) {
//var_dump($row['customer_name']);
$customer_name = $row['customer_name']; // customer name
$customer_email = $row['customer_email']; // customer email
$customer_address_1 = $row['customer_address_1']; // customer address
$customer_address_2 = $row['customer_address_2']; // customer address
$customer_town = $row['customer_town']; // customer town
$customer_county = $row['customer_county']; // customer county
$customer_postcode = $row['customer_postcode']; // customer postcode
$customer_phone = $row['customer_phone']; // customer phone number
//shipping
$customer_name_ship = $row['customer_name_ship']; // customer name (shipping)
$customer_address_1_ship = $row['customer_address_1_ship']; // customer address (shipping)
$customer_address_2_ship = $row['customer_address_2_ship']; // customer address (shipping)
$customer_town_ship = $row['customer_town_ship']; // customer town (shipping)
$customer_county_ship = $row['customer_county_ship']; // customer county (shipping)
$customer_postcode_ship = $row['customer_postcode_ship']; // customer postcode (shipping)
// invoice details
$invoice_number = $row['invoice_id']; // invoice number
$invoice_date = $row['invoice_date']; // invoice date
$invoice_due_date = $row['invoice_due_date']; // invoice due date
$invoice_subtotal = $row['invoice_subtotal']; // invoice sub-total
$invoice_shipping = $row['invoice_shipping']; // invoice shipping amount
$invoice_discount = $row['invoice_discount']; // invoice discount
$invoice_vat = $row['invoice_vat']; // invoice vat
$invoice_total = $row['invoice_total']; // invoice total
$invoice_notes = $row['invoice_notes']; // Invoice notes
$invoice_status = $row['invoice_status']; // Invoice status
}
}
?>
<h1>Edit Invoice (<?php echo $getID; ?>)</h1>
<hr>
<div id="response" class="alert alert-success" style="display:none;">
×
<div class="message"></div>
</div>
<form method="post" id="create_invoice">
<input type="hidden" name="action" value="create_invoice">
<div class="row">
<div class="col-xs-5">
<h1>
<img src="<?php echo COMPANY_LOGO ?>" class="img-responsive">
</h1>
</div>
<div class="col-xs-7 text-right">
<div class="row">
<div class="col-xs-9">
<h1>INVOICE</h1>
</div>
<div class="col-xs-3">
<select name="invoice_status" id="invoice_status" class="form-control">
<option value="open" <?php if($invoice_status == "open"){?>selected<?php } ?>>Open</option>
<option value="paid" <?php if($invoice_status == "paid"){?>selected<?php } ?>>Paid</option>
</select>
</div>
</div>
<div class="col-xs-4 no-padding-right">
<div class="form-group">
<div class="input-group date" id="invoice_date">
<input type="text" class="form-control required" name="invoice_date" placeholder="Select invoice date" data-date-format="<?php echo DATE_FORMAT ?>" value="<?php echo $invoice_date; ?>" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="form-group">
<div class="input-group date" id="invoice_due_date">
<input type="text" class="form-control required" name="invoice_due_date" placeholder="Select due date" data-date-format="<?php echo DATE_FORMAT ?>" value="<?php echo $invoice_due_date; ?>" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="input-group col-xs-4 float-right">
<span class="input-group-addon">#<?php echo INVOICE_PREFIX ?></span>
<input type="text" name="invoice_id" id="invoice_id" class="form-control required" placeholder="Invoice Number" aria-describedby="sizing-addon1" value="<?php echo $getID; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="panel panel-default">
<div class="panel-heading">
<h4>Customer Information</h4>
<div class="clear"></div>
</div>
<div class="panel-body form-group form-group-sm">
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<input type="text" class="form-control margin-bottom copy-input required" name="customer_name" id="customer_name" placeholder="Enter name" tabindex="1" value="<?php echo $customer_name; ?>">
</div>
<div class="form-group">
<input type="text" class="form-control margin-bottom copy-input required" name="customer_address_1" id="customer_address_1" placeholder="Address 1" tabindex="3" value="<?php echo $customer_address_1; ?>">
</div>
<div class="form-group">
<input type="text" class="form-control margin-bottom copy-input required" name="customer_town" id="customer_town" placeholder="Town" tabindex="5" value="<?php echo $customer_town; ?>">
</div>
<div class="form-group no-margin-bottom">
<input type="text" class="form-control copy-input required" name="customer_postcode" id="customer_postcode" placeholder="Postcode" tabindex="7" value="<?php echo $customer_postcode; ?>">
</div>
</div>
<div class="col-xs-6">
<div class="input-group float-right margin-bottom">
<span class="input-group-addon">#</span>
<input type="email" class="form-control copy-input required" name="customer_email" id="customer_email" placeholder="E-mail address" aria-describedby="sizing-addon1" tabindex="2" value="<?php echo $customer_email; ?>">
</div>
<div class="form-group">
<input type="text" class="form-control margin-bottom copy-input" name="customer_address_2" id="customer_address_2" placeholder="Address 2" tabindex="4" value="<?php echo $customer_address_2; ?>">
</div>
<div class="form-group">
<input type="text" class="form-control margin-bottom copy-input required" name="customer_county" id="customer_county" placeholder="County" tabindex="6" value="<?php echo $customer_county; ?>">
</div>
<div class="form-group no-margin-bottom">
<input type="text" class="form-control required" name="customer_phone" id="invoice_phone" placeholder="Phone number" tabindex="8" value="<?php echo $customer_phone; ?>">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-6 text-right">
<div class="panel panel-default">
<div class="panel-heading">
<h4>Shipping Information</h4>
</div>
<div class="panel-body form-group form-group-sm">
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<input type="text" class="form-control margin-bottom required" name="customer_name_ship" id="customer_name_ship" placeholder="Enter name" tabindex="9" value="<?php echo $customer_name_ship; ?>">
</div>
<div class="form-group">
<input type="text" class="form-control margin-bottom" name="customer_address_2_ship" id="customer_address_2_ship" placeholder="Address 2" tabindex="11" value="<?php echo $customer_address_2_ship; ?>">
</div>
<div class="form-group no-margin-bottom">
<input type="text" class="form-control required" name="customer_county_ship" id="customer_county_ship" placeholder="County" tabindex="13" value="<?php echo $customer_county_ship; ?>">
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<input type="text" class="form-control margin-bottom required" name="customer_address_1_ship" id="customer_address_1_ship" placeholder="Address 1" tabindex="10" value="<?php echo $customer_address_1_ship; ?>">
</div>
<div class="form-group">
<input type="text" class="form-control margin-bottom required" name="customer_town_ship" id="customer_town_ship" placeholder="Town" tabindex="12" value="<?php echo $customer_town_ship; ?>">
</div>
<div class="form-group no-margin-bottom">
<input type="text" class="form-control required" name="customer_postcode_ship" id="customer_postcode_ship" placeholder="Postcode" tabindex="14" value="<?php echo $customer_postcode_ship; ?>">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- / end client details section -->
<table class="table table-bordered" id="invoice_table">
<thead>
<tr>
<th width="500">
<h4><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Item</h4>
</th>
<th>
<h4>Qty</h4>
</th>
<th>
<h4>Price</h4>
</th>
<th width="300">
<h4>Discount</h4>
</th>
<th>
<h4>Sub Total</h4>
</th>
</tr>
</thead>
<tbody>
<?php
foreach($invoice_product as $key => $value) {
$item_product = $value;
// $item_description = $_POST['invoice_product_desc'][$key];
$item_qty = $row['invoice_product_qty'][$key];
$item_price = $row['invoice_product_price'][$key];
$item_discount = $row['invoice_product_discount'][$key];
$item_subtotal = $row['invoice_product_sub'][$key];
?>
<tr>
<td>
<div class="form-group form-group-sm no-margin-bottom">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
<input type="text" class="form-control form-group-sm item-input invoice_product" name="invoice_product[]" placeholder="Enter item title and / or description" value="<?php echo $item_product; ?>">
<p class="item-select">or select an item</p>
</div>
</td>
<td class="text-right">
<div class="form-group form-group-sm no-margin-bottom">
<input type="text" class="form-control calculate" name="invoice_product_qty[]" value="1" value="<?php echo $item_qty; ?>">
</div>
</td>
<td class="text-right">
<div class="input-group input-group-sm no-margin-bottom">
<span class="input-group-addon"><?php echo CURRENCY ?></span>
<input type="text" class="form-control calculate invoice_product_price required" name="invoice_product_price[]" aria-describedby="sizing-addon1" placeholder="0.00" value="<?php echo $item_price; ?>">
</div>
</td>
<td class="text-right">
<div class="form-group form-group-sm no-margin-bottom">
<input type="text" class="form-control calculate" name="invoice_product_discount[]" placeholder="Enter % or value (ex: 10% or 10.50)" value="<?php echo $item_discount; ?>">
</div>
</td>
<td class="text-right">
<div class="input-group input-group-sm">
<span class="input-group-addon"><?php echo CURRENCY ?></span>
<input type="text" class="form-control calculate-sub" name="invoice_product_sub[]" id="invoice_product_sub" value="0.00" aria-describedby="sizing-addon1" value="<?php echo $item_subtotal; ?>" disabled>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div id="invoice_totals" class="padding-right row text-right">
<div class="col-xs-6">
<div class="input-group form-group-sm textarea no-margin-bottom">
<textarea class-"form-control" name="invoice_notes" placeholder="Please enter any order notes here." value="<?php echo $invoice_notes; ?>"></textarea>
</div>
</div>
<div class="col-xs-6 no-padding-right">
<div class="row">
<div class="col-xs-3 col-xs-offset-6">
<strong>Sub Total:</strong>
</div>
<div class="col-xs-3">
<?php echo CURRENCY ?><span class="invoice-sub-total"> <?php echo $invoice_subtotal; ?></span>
<input type="hidden" name="invoice_subtotal" id="invoice_subtotal" value="<?php echo $invoice_subtotal; ?>">
</div>
</div>
<div class="row">
<div class="col-xs-3 col-xs-offset-6">
<strong>Discount:</strong>
</div>
<div class="col-xs-3">
<?php echo CURRENCY ?><span class="invoice-discount"> <?php echo $invoice_discount; ?></span>
<input type="hidden" name="invoice_discount" id="invoice_discount" value="<?php echo $invoice_discount; ?>">
</div>
</div>
<div class="row">
<div class="col-xs-3 col-xs-offset-6">
<strong class="shipping">Shipping:</strong>
</div>
<div class="col-xs-3">
<div class="input-group input-group-sm">
<span class="input-group-addon"><?php echo CURRENCY ?></span>
<input type="text" class="form-control calculate shipping" name="invoice_shipping" aria-describedby="sizing-addon1" placeholder="0.00" value="<?php echo $invoice_shipping; ?>">
</div>
</div>
</div>
<?php if (ENABLE_VAT == true) { ?>
<div class="row">
<div class="col-xs-3 col-xs-offset-6">
<strong>TAX/VAT:</strong>
</div>
<div class="col-xs-3">
<?php echo CURRENCY ?><span class="invoice-vat" data-enable-vat="<?php echo ENABLE_VAT ?>" data-vat-rate="<?php echo VAT_RATE ?>" data-vat-method="<?php echo VAT_INCLUDED ?>">0.00</span>
<input type="hidden" name="invoice_vat" id="invoice_vat">
</div>
</div>
<?php } ?>
<div class="row">
<div class="col-xs-3 col-xs-offset-6">
<strong>Total:</strong>
</div>
<div class="col-xs-3">
<?php echo CURRENCY ?><span class="invoice-total"> <?php echo $invoice_total; ?></span>
<input type="hidden" name="invoice_total" id="invoice_total" value="<?php echo $invoice_total; ?>">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 margin-top btn-group">
<input type="submit" id="action_edit_invoice" class="btn btn-success float-right" value="Update Invoice" data-loading-text="Updating...">
</div>
</div>
</form>
<div id="insert" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Select an item</h4>
</div>
<div class="modal-body">
<?php popProductsList(); ?>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-primary" id="selected">Add</button>
<button type="button" data-dismiss="modal" class="btn">Cancel</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php
include('footer.php');
?>
Try this out:
SELECT p.*, i.*, c.*
FROM invoice_items p
JOIN invoices i ON i.invoice = p.invoice
JOIN customers c ON c.invoice = i.invoice
WHERE p.invoice = '" . $mysqli->real_escape_string($getID) . "'
Please make sure that:
i.invoice, c.invoice and p.invoice exists and has an index on each table
PS: This query will return multiple entries depending on how many invoice_items are stored for the selected invoice
Try with this query
SELECT *
FROM invoices i,customers c,invoice_items p where
c.invoice = i.invoice and p.invoice = i.invoice and
i.invoice = '".$getID."' ORDER BY i.invoice
if ($mysqli->query("SELECT *
FROM invoices i,customers c,invoice_items p where
c.invoice = i.invoice and p.invoice = i.invoice and
i.invoice = '".$getID."' ORDER BY i.invoice") === TRUE) {
printf("No Error Message.\n");
}
Try run the query directly in database console to see if you can get results. If not, you need check your data.
Also you are using direct input to build your query, which is dangerous. You need somehow convert the getid to make sure it's a number and only a number.
i had form that is add some fields via jquery when i click " add new " button it will update a dom , with input fields . Input fields are using a array as a name , when i click submit button , values did not post to php, only static form values are posted but not dynamically generated input values .
My fiddle is http://jsfiddle.net/4L9Rc/
It will demonstrate clearly how is my form working .
HTML
<div class="row">
<div class="col-md-12">
<form method="POST" action="http://fabtech.com/invoices/create" accept-charset="UTF-8" role="form" class="form-horizontal re-form form-inv"><input name="_token" type="hidden" value="aLngVzB1UIlY6cEedbAh55tirXGGkYJl78BL0CRN"> <legend>Invoice Details</legend>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">Invoice No</label>
<div class="col-md-7">
<input type="text" placeholder="Enter invoice no" class="form-control" name="inv_no" value=""">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Invoice date</label>
<div class="col-md-7">
<input type="text" placeholder="Enter text" class="form-control date-pic" name="inv_date" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Customer</label>
<div class="col-md-7">
<select class="form-control" name="inv_customer">
<option value="">- Select Customer -</option>
<option value="suresh">suresh</option>
<option value="ABC210">ABC210</option>
<option value="QWERTy123DF">QWERTy123DF</option>
<option value="CUS002">CUS002</option>
<option value="CUS0023">CUS0023</option>
<option value="CUS003">CUS003</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">PO No</label>
<div class="col-md-7">
<input type="text" placeholder="Enter text" class="form-control" name="po_no" value="">
</div> </div>
<div class="form-group">
<label class="col-md-4 control-label">PO date</label>
<div class="col-md-7">
<input type="text" placeholder="DD/MM/YYY" class="form-control date-pic" name="po_date" value="">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">Vendor code</label>
<div class="col-md-7">
<input type="text" placeholder="Enter Vendor Code" class="form-control" name="vendor_code" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">75% abatement value</label>
<div class="col-md-1">
<input type="checkbox" class="form-control sf" name="sf">
</div>
<div class="col-md-6 sfbox" style="display:none">
<input type="text" class="form-control sfboxval" readonly="">
</div> </div>
<div class="form-group">
<label class="col-md-4 control-label">25% Taxable Value</label>
<div class="col-md-1">
<input type="checkbox" class="form-control tf" name="tf">
</div>
<div class="col-md-6 tfbox" style="display:none" >
<input type="text" class="form-control tfboxval" readonly="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Tax in %</label>
<div class="col-md-7">
<input type="text" placeholder="" class="form-control tax" name="tax" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Grand Total</label>
<div class="col-md-7">
<input type="text" placeholder="" class="form-control grandtotal" readonly="" name="grand_total">
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<legend>Particulars
<a class="btn btn-xs btn-success" id="apm"><i class="icon-plus"></i> Add new</a>
</legend>
<table id="apmr" width="69%" class="table table-striped table-bordered table-hover invoice">
<thead>
<tr>
<th width="3%">SL No</th>
<th width="25%">Description</th>
<th width="8%">Unit</th>
<th width="8%">Qty</th>
<th width="10%">Unit rate</th>
<th width="9%"> Amount</th>
</tr>
</thead>
<tbody class="roo">
<tr>
<td valign="center"> 1 </td>
<td class="tr_nt"><input type="text" name="parti[1][desc]" class="part"></td>
<td class="tr_nt"><input type="text" name="parti[1][unit]" class="part"></td>
<td class="tr_qty into"><input type="text" name="parti[1][qty]" class="part qty"></td>
<td class="tr_urate into"><input type="text" name="parti[1][urate]" class="part ur"></td>
<td class="tr_amt"><input type="text" name="parti[1][amount]" readonly="" class="part tot"></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">
</td>
<td colspan="2">
Particular's Total: Rs <span class="parttotal"></span>
</td>
</tr>
</tfoot>
</table>
<p style="text-align: center;padding-top: 5px;"><input name="submit" class="btn-lg btn-primary" type="submit" value="View Invoice"></p>
</form> </div>
</div>
</div>
</div>
Javascript
//invoice particulars
var val;
$("#apm").click(function(event) {
//event.preventDefault();
//var preData = $("#apmr tr:last").html();
//console.log(preData);
//
//$("#apmr tr:last").after('<tr>' + preData + '</tr>');
var lasttd = $('.roo tr:last td:first').text();
val = parseInt(lasttd) + 1;
$(".roo tr:last").after(' <tr> <td valign="center"> ' + val + ' </td> <td class="tr_nt"><input type="text" name="parti[' + val + '][desc]" class="part"></td> <td class="tr_nt"><input type="text" name="parti[' + val + '][unit]" class="part"></td> <td class="tr_qty into"><input type="text" name="parti[' + val + '][qty]" class="part qty"></td> <td class="tr_urate into"><input type="text" name="parti[' + val + '][urate]" class="part ur"></td> <td class="tr_amt"><input type="text" name="parti[' + val + '][amount]" readonly class="part tot" ></td></tr>');
// val = val + 1;
return false;
})
var gt;
$("table.invoice").on("change", '.qty, .ur', function(event) {
calculateRow($(this).closest("tr"));
calculateTotal();
});
function calculateRow(row) {
var price = +row.find('.qty').val();
var qty = +row.find('.ur').val();
row.find('.tot').val((price * qty).toFixed(2));
}
function calculateTotal() {
var Total = 0;
$("table.invoice").find('.tot').each(function() {
Total += +$(this).val();
});
$(".parttotal").text(Total.toFixed(2));
calgrand();
}
$(".re-form").on('change', '.tax,.tf,.sf', function(event) {
calgrand();
})
function calgrand() {
var taxVal = $('.tax').val();
var parVal = $(".parttotal").text();
var result = parVal - taxVal * parVal / 100;
$('.grandtotal').val(result.toFixed(2));
if ($('.tf').is(':checked')) {
var resulttf = parVal - 25 * parVal / 100;
$('.tfboxval').val(resulttf.toFixed(2));
var result = result - resulttf;
$('.grandtotal').val(result.toFixed(2));
}
if ($('.sf').is(':checked')) {
//alert('entered');
var resultsf = parVal - 75 * parVal / 100;
$('.sfboxval').val(resultsf.toFixed(2));
var result = result - resultsf;
$('.grandtotal').val(result.toFixed(2));
}
}
$('.tf').click(function() {
$(".tfbox").toggle(this.checked);
});
$('.sf').click(function() {
$(".sfbox").toggle(this.checked);
});
in php i had
print_r($_POST['parti']);
its give out put
Array
(
[1] => Array
(
[desc] =>
[unit] =>
[qty] =>
[urate] =>
[amount] =>
)
)
but i need
Array
(
[1] => Array
(
[desc] =>
[unit] =>
[qty] =>
[urate] =>
[amount] =>
)
[2] => Array
(
[desc] =>
[unit] =>
[qty] =>
[urate] =>
[amount] =>
)
[3] => Array
(
[desc] =>
[unit] =>
[qty] =>
[urate] =>
[amount] =>
)
....
)
javascript
Please indent your code next time. Too many changes to make in your form. At the line where you have "Enter invoice no." you have left an open quote at value=""" which is a big mistake.
Overwrite your HTML code with this:
<div class="matter">
<div class="container">
<form method="POST" action="http://fabtech.com/invoices/create" accept-charset="UTF-8" role="form" class="form-horizontal re-form form-inv">
<input name="_token" type="hidden" value="aLngVzB1UIlY6cEedbAh55tirXGGkYJl78BL0CRN">
<div class="row">
<div class="col-md-12">
<legend>Invoice Details</legend>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">Invoice No</label>
<div class="col-md-7">
<input type="text" placeholder="Enter invoice no" class="form-control" name="inv_no" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Invoice date</label>
<div class="col-md-7">
<input type="text" placeholder="Enter text" class="form-control date-pic" name="inv_date" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Customer</label>
<div class="col-md-7">
<select class="form-control" name="inv_customer">
<option value="">- Select Customer -</option>
<option value="suresh">suresh</option>
<option value="ABC210">ABC210</option>
<option value="QWERTy123DF">QWERTy123DF</option>
<option value="CUS002">CUS002</option>
<option value="CUS0023">CUS0023</option>
<option value="CUS003">CUS003</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">PO No</label>
<div class="col-md-7">
<input type="text" placeholder="Enter text" class="form-control" name="po_no" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">PO date</label>
<div class="col-md-7">
<input type="text" placeholder="DD/MM/YYY" class="form-control date-pic" name="po_date" value="">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 control-label">Vendor code</label>
<div class="col-md-7">
<input type="text" placeholder="Enter Vendor Code" class="form-control" name="vendor_code" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">75% abatement value</label>
<div class="col-md-1">
<input type="checkbox" class="form-control sf" name="sf">
</div>
<div class="col-md-6 sfbox" style="display:none">
<input type="text" class="form-control sfboxval" readonly="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">25% Taxable Value</label>
<div class="col-md-1">
<input type="checkbox" class="form-control tf" name="tf">
</div>
<div class="col-md-6 tfbox" style="display:none">
<input type="text" class="form-control tfboxval" readonly="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Tax in %</label>
<div class="col-md-7">
<input type="text" placeholder="" class="form-control tax" name="tax" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Grand Total</label>
<div class="col-md-7">
<input type="text" placeholder="" class="form-control grandtotal" readonly="" name="grand_total">
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<legend>Particulars <a class="btn btn-xs btn-success" id="apm"><i class="icon-plus"></i> Add new</a>
</legend>
<table id="apmr" width="69%" class="table table-striped table-bordered table-hover invoice">
<thead>
<tr>
<th width="3%">
SL No
</th>
<th width="25%">
Description
</th>
<th width="8%">
Unit
</th>
<th width="8%">
Qty
</th>
<th width="10%">
Unit rate
</th>
<th width="9%">
Amount
</th>
</tr>
</thead>
<tbody class="roo">
<tr>
<td valign="center">
1
</td>
<td class="tr_nt">
<input type="text" name="parti[1][desc]" class="part">
</td>
<td class="tr_nt">
<input type="text" name="parti[1][unit]" class="part">
</td>
<td class="tr_qty into">
<input type="text" name="parti[1][qty]" class="part qty">
</td>
<td class="tr_urate into">
<input type="text" name="parti[1][urate]" class="part ur">
</td>
<td class="tr_amt">
<input type="text" name="parti[1][amount]" readonly="" class="part tot">
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">
</td>
<td colspan="2">
Particular's Total: Rs <span class="parttotal"></span>
</td>
</tr>
</tfoot>
</table>
<p style="text-align: center;padding-top: 5px;">
<input name="submit" class="btn-lg btn-primary" type="submit" value="View Invoice">
</p>
</div>
</div>
</form>
</div>
</div>
Your mistake was that your <form> tag was closed in the wrong place. Remember to always place tags in such a way that always the inner tags close first.