I am new to PHP. When I am trying to update or modify my form then it is not getting updated in the phpmyadmin database table. I am using AJAX, jQuery, and PHP. I am badly stuck here so can anyone guide me that how to solve this issue. Thanks in advance. Following are the codes guys.
update_details.php
<div class="panel-body">
<?php
$q1="SELECT * FROM `plantation_journal_basic_details` WHERE `plantation_journal_no`='$plantation_journal_no' ";
$r1=mysqli_query($con,$q1);
$ro1=mysqli_fetch_array($r1);
?>
<form id="form1" action="update_details.php?id='<?php echo $plantation_journal_no; ?>'" name="form1" method="post">
<div class="row">
<div class="col-sm-4">
<h4 style="font-size: 16px;"><b>Basic Details:</b></h4><br>
<div align="right" style="padding-right: 10px;" >
<div align="right" style="padding-right: 10px;" >
<label style="font-weight:300;font-size: 15px">Scheme:</label>
<label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['scheme']; ?></label><br><br>
<label style="font-weight:300;font-size: 15px">Year:</label>
<label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['year']; ?></label><br><br>
<label style="font-weight:300;font-size: 15px">Range:</label>
<label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['ranges']; ?></label><br><br>
<label style="font-weight:300;font-size: 15px">Beat:</label>
<label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['beat']; ?></label><br><br>
<label style="font-weight:300;font-size: 15px">JFMC:</label>
<label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['jfmc']; ?></label><br><br>
<label style="font-weight:300;font-size: 15px">Panchayat Samity:</label>
<label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['panchayat_samity']; ?></label><br><br>
<label style="font-weight:300;font-size: 15px">Gram Panchayat:</label>
<label align="left" style="width:50%;margin-left: 10px;font-weight:300;font-size: 15px"><?php echo $ro1['gram_panchayat']; ?></label><br><br>
</div>
</div>
</div>
<div class="col-sm-4">
<h4 style="font-size: 16px;"><b>GPS Coordinates:</b></h4><br>
<div align="right" style="padding-right: 10px;" >
<label style="font-weight:300;font-size: 15px">Latitude:</label>
<input type="text" name="latitude_degree" value="<?php echo $ro1['latitude_degree']; ?>" style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px; padding: 0 0 0 1px;">
<label style="font-weight:300;font-size: 15px">°</label>
<input type="text" name="latitude_minute" value="<?php echo $ro1['latitude_minute']; ?>" style="width:10%;height: 30px; margin-left: 10px; padding: 0 0 0 1px; border-radius: 5px;">
<label style="font-weight:300;font-size: 15px">'</label>
<input type="text" name="latitude_second" value="<?php echo $ro1['latitude_second']; ?>" style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px; padding: 0 0 0 1px;">
<label style="font-weight:300;font-size: 15px">"</label><br>
<label style="font-weight:300;font-size: 15px">Longitude:</label>
<input type="text" name="longitude_degree" value="<?php echo $ro1['longitude_degree']; ?>" style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px; padding: 0 0 0 1px;">
<label style="font-weight:300;font-size: 15px">°</label>
<input type="text" name="longitude_minute" value="<?php echo $ro1['longitude_minute']; ?>" style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px; padding: 0 0 0 1px;">
<label style="font-weight:300;font-size: 15px">'</label>
<input type="text" name="longitude_second" value="<?php echo $ro1['longitude_second']; ?>" style="width:10%;height: 30px; margin-left: 10px; border-radius: 5px; padding: 0 0 0 1px;">
<label style="font-weight:300;font-size: 15px">"</label><br>
</div>
<h4 style="font-size: 16px;"><b>Boundary:</b></h4><br>
<div align="right" style="padding-right: 10px;" >
<label style="font-weight:300;font-size: 15px">North:</label>
<input type="text" name="north" value="<?php echo $ro1['north']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">East:</label>
<input type="text" name="east" value="<?php echo $ro1['east']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">West:</label>
<input type="text" name="west" value="<?php echo $ro1['west']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">South:</label>
<input type="text" name="south" value="<?php echo $ro1['south']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
</div>
</div>
<div class="col-sm-4">
<h4 style="font-size: 16px;"><b>Surveyed By:</b></h4><br>
<div align="right" style="padding-right: 10px;" >
<label style="font-weight:300;font-size: 15px">Full Name:</label>
<input type="text" name="full_name_s" value="<?php echo $ro1['ful_name_s']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Designation:</label>
<input type="text" name="designation_s" value="<?php echo $ro1['designation_s']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
</div>
<h4 style="font-size: 16px;"><b>Checked By:</b></h4><br>
<div align="right" style="padding-right: 10px;" >
<label style="font-weight:300;font-size: 15px">Full Name:</label>
<input type="text" name="full_name_c" value="<?php echo $ro1['full_name_c']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Designation:</label>
<input type="text" name="designation_c" value="<?php echo $ro1['designation_c']; ?>" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
</div>
</div>
</div>
<br>
<div align="right">
<input class="btn btn-info btn-submit8" type="submit" name="submit_1" value="Add" onclick="move1()">
</div>
</form>
<?php
if(isset($_POST['latitude_degree'])){
$latitude_degree=$_POST['latitude_degree'];
$latitude_minute=$_POST['latitude_minute'];
$latitude_second=$_POST['latitude_second'];
$longitude_degree=$_POST['longitude_degree'];
$longitude_minute=$_POST['longitude_minute'];
$longitude_second=$_POST['longitude_second'];
$north=$_POST['north'];
$east=$_POST['east'];
$west=$_POST['west'];
$south=$_POST['south'];
$full_name_s=$_POST['full_name_s'];
$designation_s=$_POST['designation_s'];
$full_name_c=$_POST['full_name_c'];
$designation_c=$_POST['designation_c'];
$sql="UPDATE `plantation_journal_basic_details` SET `latitude_degree`='$latitude_degree',`latitude_minute`='$latitude_minute',`latitude_second`='$latitude_second',`longitude_degree`='$longitude_degree',`longitude_minute`='$longitude_minute',`longitude_second`='$longitude_second',`north`='$north',`east`='$east',`west`='$west',`south`='$south',`ful_name_s`='$full_name_s',`designation_s`='$designation_s',`full_name_c`='$full_name_c',`designation_c`='$designation_c' WHERE `plantation_journal_no`='$plantation_journal_no'";
$result=mysqli_query($con,$sql);
}
?>
A simpler way to submit all your input values is with:
$('#form').ajaxForm({
/*....*/
});
Did you try it?
Related
After more than a month of coding I though I'm already finish it that's why I put it on hosting already, but after I check it on my mobile phone it shock me of the result :(
This is the result in mobile
Form image
Form image with table
anyone can give me an idea on what should I do? i dont want to make from scratch again this is my css, this is two column in 1 page with form in the left and table in the right
body {
font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
h3 {
position:relative;
text-align: center;
margin: 0;
font-size: 32px;
color: #fff;
z-index: 2;
}
.column {
float: left;
padding: 10px;
}
.left {
padding: 25px;
margin: 25px;
width: 40%;
border-radius: 5px;
box-shadow: 1 2px 5px #f5f5f5;
background: white;
border: solid 1px #ccc;
border: 2px solid dodgerblue;
}
.right {
padding: 25px;
margin: 25px;
width: 50%;
border-radius: 5px;
box-shadow: 1 2px 5px #f5f5f5;
background: white;
border: 2px solid dodgerblue;
}
.row:after {
content: "";
display: table;
clear: both;
}
input[type="text"]
{
display: inline-block;
float: left;
padding: 12px; line-height: 5px;
margin: 5px;
height: 40px;
}
label {
display: inline-block;
width: 150px;
padding-left: 5px
}
.main-block {
display: flex;
justify-content: center;
min-height: 100vh;
background-color: #85C1E9;
}
.btn-block {
margin-top: 10px;
text-align: center;
}
button {
outline: none;
font-family: Roboto, Arial, sans-serif;
border: none;
border-radius: 5px;
background: #00BFFF;
font-size: 50px;
color: #fff;
cursor: pointer;
}
button:hover {
background: cyan;
}
.msg {
margin: 30px auto;
padding: 10px;
border-radius: 5px;
color: #3c763d;
background: #dff0d8;
border: 1px solid #3c763d;
width: 50%;
text-align: center;
}
.mix3 {
margin: 0px;
width: 100%;
border-width: strong;
padding: 10px 10px;;
}
This is the form
<div class="main-block">
<div class="column left">
<i class="fa fa-window-restore"></i>
<div class="mix3">
<h5 style="text-align: center; margin-bottom:-10px"><b style="color:red"> STATUS:<a style="color:blue"> <?php echo $status; ?></a></b></h5>
</div>
<form name="frmUser" method="post">
<div><?php if(isset($message)) { echo $message; } ?>
</div>
<div >
<h3><b>Payment Voucher Form </b></h3>
</div>
<div style="margin-bottom:10px; margin-top:20px; " class="bootstrap-demo">
<label style="margin-left: 20px; font-weight: bold;" class="checkbox-inline"> <!-- class checkbox-inline to display checkbox inline -->
<!-- input type checkbox -->
<input type="checkbox" id="cashbox" value="Cash"> Cash
</label>
<label style="margin-left: -50px; font-weight: bold;" class="checkbox-inline">
<input type="checkbox" id="chequebox" value="Cheque"> Cheque
</label>
<label style="margin-left: -50px; margin-right: -30px; font-weight: bold;" class="checkbox-inline">
<input type="checkbox" id="banktransferbox" value="BankTransfer"> Bank Transfer
</label>
</div>
<input type="hidden" name="userid" class="txtField" value="<?php echo $row['ID']; ?>">
<div class="form-row">
<input type="hidden" name="id" class="txtField" value="<?php echo $row['ID']; ?>">
<div class="col-md-7 mb-2">
<label>Payment Voucher ID</label>
<input placeholder="Payment Voucher ID" id ="pv_no" type="text" name="pvid" class="form-control" value="<?php echo $row['PViD']; ?>">
</div>
<div class="col-md-5 mb-2">
<label>Date</label>
<input placeholder="Date" type="text" id="pvdate" name="pvdate" class="form-control" value="<?php echo $row['PVDate']; ?>">
</div>
<div class="col-md-7 mb-2">
<label>Paid to</label>
<input placeholder="Paid to" type="text" name="pvname" class="form-control" value="<?php echo $row['Name']; ?>">
</div>
<div class="col-md-5 mb-2">
<label>Contact No.</label>
<input placeholder="Contact #" type="text" name="contactnumber" class="form-control" value="<?php echo $row['ContactNumber']; ?>">
</div>
<div class="mb-2" style="padding-left: 20px">
<label>The Sum of</label>
<textarea placeholder="The Sum of" name="suminwords" class="form-control"><?php echo $row['SumInWords']; ?></textarea>
</div>
<div class="mb-2" style="padding-left: 20px">
<label>In Respect of</label>
<textarea placeholder="Respectof" name="respectof" class="form-control"><?php echo $row['RespectOf']; ?></textarea>
</div>
<div class="col-md-6 mb-2">
<label>Price</label>
<input placeholder="Total" type="text" name="price" class="form-control" value="<?php echo $row['Price']; ?>">
</div>
<div class="col-md-6 mb-2" >
<label>Cash</label>
<input placeholder="Cash" type="text" name="cash" class="form-control" value="<?php echo $row['Cash']; ?>">
</div>
<div class="col-md-6 mb-2" style="float:right">
<label>Bank Name</label>
<input placeholder="Bank Name" type="text" name="bankname" class="form-control" value="<?php echo $row['BankName']; ?>">
</div>
<div class="col-md-6 mb-2">
<label>VAT 5%</label>
<input placeholder="VAT" type="text" name="vat" class="form-control" value="<?php echo $row['VAT']; ?>">
</div>
<div class="col-md-6 mb-2">
<label>Total</label>
<input placeholder="Total" type="text" name="total" class="form-control" value="<?php echo $row['Total']; ?>">
</div>
<div class="col-md-6 mb-2">
<label>Cheque No</label>
<input placeholder="Cheque No" type="text" name="chequenumber" class="form-control" value="<?php echo $row['ChequeNumber']; ?>">
</div>
<div class="col-md-6 mb-2" style="float:right">
<label>Cheque Date</label>
<input placeholder="Cheque Date" type="text" id="cheque_date" name="chequedate" class="form-control" value="<?php echo $row['ChequeDate']; ?>">
</div>
<div style="margin-bottom: 150px"> </div>
<label class="col-md-8"> Remarks</label>
<div class="mb-2" style="padding-left: 20px">
<textarea placeholder="Remarks" name="remarks" class="form-control"><?php echo $row['Remarks']; ?></textarea>
</div>
<br>
<div class="col-md-6 mb-2" style="float:right">
<label>Prepared By </label>
<input placeholder="Cheque No." type="text" name="preparedby" class="form-control" value="<?php echo $row['PreparedBy']; ?>">
</div>
<div class="col-md-6 mb-2" style="float:right">
<label>Approved By </label>
<input placeholder="Cheque No." type="text" name="approvedby" class="form-control" value="<?php echo $row['ApprovedBy']; ?>">
</div>
<br><br><br><br><br>
<div class="col-md-6 mb-2" style="float:right">
<label>Received By </label>
<input placeholder="Received By" type="text" name="receivedby" class="form-control" value="<?php echo $row['ReceivedBy']; ?>">
</div>
</div>
<div class="col-md-10 mb-1">
<div class="btn-block">
<button style="width:40%; padding: 10px; box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19); color:black; margin-left: 20px" type="submit" name="submit" value="Submit"><b>Update / Add Record</b></button>
</div>
</div>
</form>
<button onclick="location.href='/payment-voucher'" type="button" style="width:30%; color:white; box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19); background-color:red; font-size: 15px; float:right; padding: 15px;"><b>Clear</b></button>
</div>
<div class="column right">
<i class="fa fa-window-restore"></i>
<div>
<h3><b>Payment Voucher List </b></h3>
</div>
<div class="col-md-6">
<input size="50" type="text" name="search" id="search" class="form-control" placeholder="Search name.." />
</div>
<br><br><br>
<div class="col-md-4">
<input type="text" name="from_date" id="from_date" class="form-control" placeholder="From Date" />
</div>
<div class="col-md-4">
<input type="text" name="to_date" id="to_date" class="form-control" placeholder="To Date" />
</div>
<div class="col-md-5">
<input type="button" name="filter" id="filter" value="Search" class="btn btn-info" />
</div>
<div style="clear:both"></div>
<br>
<div id="pvoucher">
<table class="table table-bordered">
<tr style="background-color: #85C1E9; color:white; ">
<th>ID</th>
<th>PVID</th>
<th>PVDate</th>
<th>Name</th>
<th>Update</th>
<th>Delete</th>
<th>Print</th>
</tr>
</table>
<?php if (isset($_SESSION['message'])):
$e = $_SESSION['message'];
?>
<div class="msg">
<?php
$e = $_SESSION['message'];
echo '<tr>';
echo '<td colspan="5">'. $e . '</td>';
echo '</tr>';
unset($_SESSION['message']);
?>
</div>
<?php endif
?>
</div>
</div>
</div>
You should use #media and for example when width of window is smaller than 700px set one column. You should also add meta tag to your html to give browser tips how should scal your website on mobile phones.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
I am trying to update specific row in tables using button tag .But it is updating last inserted row only and not the selected button tag.
Model
public function title_d($data,$title_id)
{
$this->db->where('title_id',$title_id);
$this->db->update('experience',$data);
}
view
<form method="POST" action="http://localhost/portfolio/user/title">
<?php
foreach($experience->result() as $values1) {
?>
<section class="row">
<section class="border mt-5 m-auto p-5" style="background: #fff; width: 30%; height: 250px;">
<input type="text" value="<?php echo $values1->title_id;?>" name="title_id" hidden />
<h5>Title</h5>
<input type="text" value="<?php echo $values1->title;?>" class="form-control place" name="title" style="width: 200px; height: 30px; border: 1px solid;">
</section>
<section class="border mt-5 m-auto p-4" style="background: #fff; width: 23%;height: 250px;">
<h5>Write What you know</h5>
<textarea style=" height: 150px; width: 180px;" name="write">
<?php echo $values1->write;?>
</textarea>
</section>
<section class="border mt-5 m-auto p-5" style="background: #fff; width: 25%; height: 250px; ">
<h5>update your details</h5>
<button type="submit" value="<?php echo $values1->title_id; ?>" style="background:#1C8ACA; height: 40px; " class="btn btn-primary">Update<?php echo $values1->title_id; ?></button>
<button type="submit" value="<?php echo $values1->title_id; ?>"style="background:#ff0000; height: 40px; " class="btn btn-danger">Delete<?php echo $values1->title_id;?></button>
</section>
</section>
<?php
}
?>
</form>
controller:
Class User extends CI_Controller {
public function index()
{
$this->load->model('User_model');
$user_id = 1;
$data['admin'] = $this->User_model->admin_data($user_id);
$data['images'] = $this->User_model->get_images($user_id);
$data['names'] = $this->User_model->get_name();
$data['intro'] = $this->User_model->get_intro();
$data['experience'] = $this->User_model->get_title();
$data['contact'] = $this->User_model->get_contact();
$this->load->helper('url');
$this->load->view('Home',$data);
}
public function title()
{
$this->load->model('User_model');
$title_id = $this->input->post('title_id');
$title = $this->input->post('title');
$write = $this->input->post('write');
$data = array("title"=>$title,"write"=>$write);
$this->User_model->title_d($data,$title_id);
$this->User_model->delete_title($title_id,$data);
redirect('/');
}
}
I think you have to create your loop with the form inside, like:
<?php foreach($experience->result() as $values1) { ?>
<form method="POST" action="http://localhost/portfolio/user/title">
<section class="row">
<section class="border mt-5 m-auto p-5" style="background: #fff; width: 30%; height: 250px;">
<input type="text" value="<?php echo $values1->title_id;?>" name="title_id" hidden />
<h5>Title</h5>
<input type="text" value="<?php echo $values1->title;?>" class="form-control place" name="title" style="width: 200px; height: 30px; border: 1px solid;">
</section>
<section class="border mt-5 m-auto p-4" style="background: #fff; width: 23%;height: 250px;">
<h5>Write What you know</h5>
<textarea style=" height: 150px; width: 180px;" name="write">
<?php echo $values1->write;?>
</textarea>
</section>
<section class="border mt-5 m-auto p-5" style="background: #fff; width: 25%; height: 250px; ">
<h5>update your details</h5>
<button type="submit" value="<?php echo $values1->title_id; ?>" style="background:#1C8ACA; height: 40px; " class="btn btn-primary">Update<?php echo $values1->title_id; ?></button>
<button type="submit" value="<?php echo $values1->title_id; ?>"style="background:#ff0000; height: 40px; " class="btn btn-danger">Delete<?php echo $values1->title_id;?></button>
</section>
</section>
</form>
<?php } ?>
I am using php and MySQL. When I submit the form data is not stored in the database table 'plantation_journal_nursery_details'. I am badly stuck here. Can anyone please advice me that how can I solve this problem?? Thanks in advance guys. codes are given below :
create_journal.php
<form action="data_fetch.php" action="post">
<div class="row">
<div class="col-sm-4">
<h4 style="font-size: 16px;padding-left: 15px;"><b>Nursery Location:</b></h4><br>
<div align="right" style="padding-right: 10px;">
<label style="font-weight:300;font-size: 15px">Location:</label>
<input type="text" name="location" id="location" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Area:</label>
<input type="text" name="area1" id="area1" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">type of Nursey:</label>
<select name="type_of_nursery" id="type_of_nursery" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><br><br>
<label style="font-weight:300;font-size: 15px">Centranl Nursery Name:</label>
<select name="central_nursery_name" id="central_nursery_name" style="width:40%;height: 30px; margin-left: 10px; border-radius: 5px;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><br><br>
<label style="font-weight:300;font-size: 15px">State Nursery Name:</label>
<input type="text" name="state_nursery_name" id="state_nursery_name" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
</div>
</div>
<div class="col-sm-4">
<h4 style="font-size: 16px;padding-left: 15px;"><b>Size of Each Bed:</b></h4><br>
<div align="right" style="padding-right: 10px;">
<label style="font-weight:300;font-size: 15px">Mother Bed Size:</label>
<input type="text" name="mother_bed_size" id="mother_bed_size" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Quantity:</label>
<input type="text" name="quantity_m" id="quantity_m" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br><br><br>
<label style="font-weight:300;font-size: 15px">Source of Seed:</label>
<select name="source_of_seed" id="source_of_seed" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><br><br>
</div>
</div>
<div class="col-sm-4">
<div align="right" style="padding-right: 10px; padding-top: 40px">
<label style="font-weight:300;font-size: 15px">Polypot Bed Size:</label>
<input type="text" name="polypot_bed_size" id="polypot_bed_size" style="width:42%;height: 30px; margin-left: 4px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Quantity:</label>
<input type="text" name="quantity_p" id="quantity_p" style="width:42%;height: 30px; margin-left: 4px; border-radius: 5px;"><br><br>
<label style="font-weight:300;font-size: 15px">Hycopot Bed Size:</label>
<input type="text" name="hycopot_bed_size" id="hycopot_bed_size" style="width:42%;height: 30px; margin-left: 4px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Quantity:</label>
<input type="text" name="quantity_h" id="quantity_h" style="width:42%;height: 30px; margin-left: 4px; border-radius: 5px;"><br>
</div>
</div>
</div>
<div class="row">
<div align="right" style="padding-right: 10px;">
<input class="btn btn-info" type="submit" name="submit16" value="Add" onclick="move7()">
</div>
</div>
</form>
data_fetch.php
<?php
$con=mysqli_connect("localhost","root","","forestdb");
if(isset($_POST['submit16'])){
$location=$_POST['location'];
$area1=$_POST['area1'];
$type_of_nursery=$_POST['type_of_nursery'];
$central_nursery_name=$_POST['central_nursery_name'];
$state_nursery_name=$_POST['state_nursery_name'];
$mother_bed_size=$_POST['mother_bed_size'];
$quantity_m=$_POST['quantity_m'];
$source_of_seed=$_POST['source_of_seed'];
$polypot_bed_size=$_POST['polypot_bed_size'];
$quantity_p=$_POST['quantity_p'];
$hycopot_bed_size=$_POST['hycopot_bed_size'];
$quantity_h=$_POST['quantity_h'];
$query="SELECT plantation_journal_no from plantation_journal_basic_details where plantation_journal_no=(select max(plantation_journal_no) from plantation_journal_basic_details);";
$res=mysqli_query($con,$query);
$row=mysqli_fetch_assoc($res);
$plantation_journal_no=$row['plantation_journal_no'];
$sql="INSERT INTO `plantation_journal_nursery_details`(`plantation_journal_no`, `location`, `area`, `type_of_nursery`, `central_nursery_name`, `state_nursery_name`, `mother_bed_size`, `quantity`, `source_of_seed`, `polypot_bed_size`, `quantity_p`, `hycopot_bed_size`, `quantity_h`) VALUES ('$plantation_journal_no','$location','$area1','$type_of_nursery','$central_nursery_name','$central_nursery_name','$mother_bed_size','$quantity_m','$source_of_seed','$polypot_bed_size','$quantity_p','$hycopot_bed_size','$quantity_h');";
$result=mysqli_query($con,$sql);
if($result){
echo "<script>alert('data submitted.');</script>";
header("Location:create_journal.php");
}
}
?>
Your insert query, before you edited your question, contained ...
...VALUES ('$plantation_journal_no',$configurarion','$slope','$water_table_in_...
Notice that your single quotes aren't matched. You should have
...VALUES ('$plantation_journal_no','$configurarion','$slope','$water_table_in_...
If you had checked for an error in your query you would have found this problem immediately. Code like this would have helped.
if($result){
echo "<script>alert('data submitted.');</script>";
header("Location:create_journal.php");
}
else {
die $mysqli->error;
}
Pro tip: Format your code so you don't have to scroll horizontally to see entire queries. It's far easier to examine your queries and find mistakes that way. You can use php's heredoc syntax for string constants to do that.
This is how it looks.
$sql= <<<INSERTQUERY
INSERT INTO `plantation_journal_nursery_details`
(`plantation_journal_no`, `location`, `area`, `type_of_nursery`,
`central_nursery_name`, `state_nursery_name`, `mother_bed_size`,
`quantity`, `source_of_seed`, `polypot_bed_size`, `quantity_p`,
`hycopot_bed_size`, `quantity_h`)
VALUES
('$plantation_journal_no','$location','$area1','$type_of_nursery',
'$central_nursery_name','$central_nursery_name','$mother_bed_size',
'$quantity_m','$source_of_seed','$polypot_bed_size','$quantity_p',
'$hycopot_bed_size','$quantity_h');
INSERTQUERY;
I'm working on a registration form for a website I'm building, but can't separate the echoed error messages from the text-boxes within the form.
Every time I run it in my browser to test the error messages, the text-boxes are moved to the left (out of alignment) and the error messages appear to the right of them. Clearly it's aligned both of the objects in the center, but I only want the form fields to be centered. Any help you can offer is appreciated.
Here's my html and css code...
<!DOCTYPE html>
<html>
<head>
<title>Register</title>
<style>
body {
background-color: silver;
}
.welcome {
text-align: center;
font-family: "Arial";
font-size: 30px;
text-shadow: 2px 2px lightgrey;
color: white;
padding-top: 15px;
}
.form-group {
text-align: center;
}
input[name=username], input[name=first_name], input[name=last_name], input[name=email],
input[name=password], input[name=confirm_password] {
border: 3px solid lightgrey;
padding: 10px;
background: white;
margin: 0 0 10px 0;
width: 250px;
outline:0 !important;
}
.help-block {
font-family: "Arial";
font-size: 12pt;
color: white;
}
input[type=submit] {
color: grey;
border: 3px solid lightgrey;
padding: 5px;
width: 100px;
text-align: center;
}
input[type=submit]:focus {
outline:0 !important;
}
input[type=submit]:hover {
background-color: #ddd;
}
input[type=submit]:active {
background-color: #aaa;
color: lightgrey;
}
</style>
</head>
<div class="welcome">
<h1>Register</h1>
</div>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group <?php echo (!empty($username_err)) ? 'has-error' : ''; ?>">
<input type="text" name="username" class="form-control" value="<?php echo $username; ?>" placeholder="Username">
<span class="help-block"><?php echo $username_err; ?></span>
</div>
<div class="form-group <?php echo (!empty($first_name_err)) ? 'has-error' : ''; ?>">
<input type="text" name="first_name" class="form-control" value="<?php echo $first_name; ?>" placeholder="First Name">
<span class="help-block"><?php echo $first_name_err; ?></span>
</div>
<div class="form-group <?php echo (!empty($last_name_err)) ? 'has-error' : ''; ?>">
<input type="text" name="last_name" class="form-control" value="<?php echo $last_name; ?>" placeholder="Last Name">
<span class="help-block"><?php echo $last_name_err; ?></span>
</div>
<div class="form-group <?php echo (!empty($email_err)) ? 'has-error' : ''; ?>">
<input type="text" name="email" class="form-control" value="<?php echo $email; ?>" placeholder="Email">
<span class="help-block"><?php echo $email_err; ?></span>
</div>
<div class="form-group <?php echo (!empty($password_err)) ? 'has-error' : ''; ?>">
<input type="password" name="password" class="form-control" value="<?php echo $password; ?>" placeholder="Password">
<span class="help-block"><?php echo $password_err; ?></span>
</div>
<div class="form-group <?php echo (!empty($confirm_password_err)) ? 'has-error' : ''; ?>">
<input type="password" name="confirm_password" class="form-control" value="<?php echo $confirm_password; ?>" placeholder="Confirm Password">
<span class="help-block"><?php echo $confirm_password_err; ?></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</form>
</html>
One way would be to make the form-group's display:inline-block and position:relative. After that, you have to center the form-group's with text-align:center on the form.
Now, you could simply position the error messages absolute and move them top:0; and left: 270px (250px width of the inputs and 2*10px padding)
If you just want the error message under the input box, a simple diplay:block; text-align:center; on the help-block would be enough
my web page design remains normal until i write
once i use it, the content portion of the web just disturb code is given below
<?php echo form_open('regform/register');?>
<div class="first">
<fieldset>
<label for="name"><strong>Name:<br /></strong> </label><input type="text" name="name" maxlength="55" id="name" class="inputtext" />
<label for="email"><strong>Email:<br /></strong></label><input type="text" name="email" maxlength="55" id="email" class="inputtext" />
<label for="password"><strong>Password:<br /></strong></label><input type="text" name="password" maxlength="55" id="password" class="inputtext" />
<label for="confirmpass"><strong>Confirm Password:<br /></strong></label><input type="text" name="confirm" maxlength="55" id="confirmpass" class="inputtext" />
<div>
<label for="newsletter"><input type="checkbox" id="newsletter" /><span>Subscribe to newsletter</span></label>
<label class="terms" for="terms"><input type="checkbox" id="terms" /><span>I agree to the Terms and Conditions</span></label>
</div>
</fieldset>
</div>
<div>
<fieldset>
<label for="completename"><strong>Complete name:</strong></label><input type="text" maxlength="55" id="completename" class="inputtext" />
<label for="address"><strong>Primary address:</strong></label><input type="text" maxlength="55" id="address" class="inputtext" />
<label for="billing"><strong>Billing address:</strong></label><input type="text" maxlength="55" id="billing" class="inputtext" />
<label for="city"><strong>City:</strong></label><label class="zipcode" for="zipcode"><strong>Zip Code:</strong></label>
<input type="text" maxlength="30" id="city" />
<input type="text" maxlength="30" id="zipcode" class="zipcode" />
<div>
<label for="shipping"><input type="checkbox" id="shipping" /><span> Same Shipping and Billing address</span></label>
<label class="saveas" for="saveas"><input type="checkbox" id="saveas" /><span> Save as default address</span></label>
</div>
</fieldset>
</div>
<input type="submit" value="" id="createaccount" />
</form>
</div>
this is how it looks after using "php echo form_open"
this is .css file for that portion
content div form div {
background: url(../images/bg-form.jpg) no-repeat;
float: left;
height: 396px;
margin: 0 0 0 24px;
padding: 0;
width: 463px;
}
#content div form div.first {
margin-left: 0;
}
#content div form div fieldset {
border: 0;
margin: 20px auto;
width: 386px;
}
#content div form div fieldset input.inputtext {
background: url(../images/sprites-inputs.gif) no-repeat 0 -42px;
border: 0;
height: 31px;
margin: 10px 0;
padding: 0 5px;
width: 376px;
}
#content div form div fieldset input#city {
background: url(../images/sprites-inputs.gif) no-repeat 0 0;
border: 0;
height: 32px;
margin: 10px 0;
padding: 0 5px;
width: 172px;
}
#content div form div fieldset label.zipcode {
margin-left: 168px;
}
#content div form div fieldset input#zipcode {
background: url(../images/sprites-inputs.gif) no-repeat 0 0;
border: 0;
height: 32px;
margin: 0 0 0 15px;
padding: 0 5px;
width: 172px;
}
#content div form div div {
background: none;
float: none;
height: auto;
margin-left: 0;
margin-top: 33px;
width: auto;
}
i think You have missed classes for the form element
just use it like
echo form_open('your_url', array(
'class' => 'your classes',
'role' => 'role of form'
));