<?php
include('include/connection.php');
session_start();
$_SESSION['verify_remote_agent']=$_SERVER['HTTP_USER_AGENT'];
$r=session_id();
if(isset($next)) {
$city=$_POST['city'];
$from_city=$_POST['from_city'];
$to_city=$_POST['to_city'];
$query="INSERT INTO user_details values('$r','$city',$from_city,'$to_city')";
mysql_query($query);
}
?>
<div class="container">
<form action="index2.php" method="POST">
<div class="form-group city col-sm-4">
<select class="form-control" name="city">
<option value="choose">Choose City</option>
<option value="option[1]">Delhi/NCR</option>
<option value="others">Other</option>
</select>
</div>
<div class="form-group from_city col-sm-4">
<input type="text" class="form-control" name="from_city" placeholder="From Area">
</div>
<div class="form-group to_city col-sm-4">
<input type="text" class="form-control" name="to_city" placeholder="To Area">
</div>
<p class="text-right">
<input class="btn btn-primary" type="submit" value="Next Step" name="next">
</p>
</form>
</div>
Try this:
$query="INSERT INTO user_details values('".$r."','".$city."','".$from_city."','".$to_city."')";
mysql_query($query);
Related
There is problem in opening bootstrap modal in iphones.
If i use static modal like below,
<a href="#responsive" data-toggle="modal"><button class="btn btn-green ">Add Product<i class="fa fa-plus"></i></button>
</a>
<!-- start: BOOTSTRAP EXTENDED MODALS -->
<div id="responsive" class="modal extended-modal fade no-display">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title" style="color:red">Add New Product</h4>
</div>
<div class="modal-body">
<div class="row">
<form name="new" action="<?php echo base_url() ?>admin/addProduct" method="post" enctype="multipart/form-data" autocomplete="off">
<div class="col-md-6">
<h4><b>Category Name <span class="symbol required"></span></b></h4>
<p>
<select class="form-control" name="cat_id" required>
<option value="">---- Select Category ----</option>
<?php foreach($cat['list'] as $rows=>$value){ ?>
<option value="<?php echo $cat['list'][$rows]->cat_id; ?>"><?php echo ucwords($cat['list'][$rows]->cat_name); ?></option>
<?php } ?>
</select>
</p>
</div>
<div class="col-md-6">
<h4><b>Product Name <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="item_name" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Small Description <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="small_desc">
</p>
</div>
<div class="col-md-6">
<h4><b>Quantity<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="quantity" required min="1">
</p>
</div>
<div class="col-md-6">
<h4><b>Customer Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="price" required min="1">
</p>
</div>
<div class="col-md-6">
<h4><b>Reseller Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="reseller" required min="1">
</p>
</div>
<div class="col-md-6">
<h4><b>Color<span class="symbol "></span></b></h4>
<p>
<input class="form-control" type="text" name="color">
</p>
</div>
<div class="col-md-6">
<h4><b>Availability <span class="symbol required"></span></b></h4>
<select class="form-control" name="availability">
<option value="1">Available</option>
<option value="0">Not Available</option>
</select>
</div>
<div class="col-md-6">
<h4><b>Image <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" accept="image/*" onchange="loadFile(event)" type="file" name="userfile" required multiple>
<img id="output" width="100px" height="100px" />
</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="reset" data-dismiss="modal" class="btn btn-light-grey">
Close
</button>
<button type="submit" class="btn btn-blue">
Add Product
</button>
</div>
</form>
</div>
</div>
</div>
<!-- End Modal -->
the modal will open properly and i can enter values.
But if use the modal for editing like below,
<a href="#edit<?php echo $product['list'][$row]->item_id; ?>" data-toggle="modal">
<button class="btn btn-blue"><i class="fa fa-pencil"></i> Edit </button>
</a>
<div id="edit<?php echo $product['list'][$row]->item_id?>" class="modal extended-modal fade no-display">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title" style="color:red">Edit Product</h4>
</div>
<div class="modal-body">
<div class="row">
<form action="<?php echo base_url() ?>admin/editProduct" enctype="multipart/form-data" method="post" autocomplete="off">
<div class="col-md-6">
<h4><b>Category Name <span class="symbol required"></span></b></h4>
<p>
<select class="form-control" name="cat_id" required>
<option value="">---- Select Category ----</option>
<?php
foreach($cat['list'] as $rows=>$value){ ?>
<option value="<?php echo $cat['list'][$rows]->cat_id; ?>"<?php if($cat['list'][$rows]->cat_id == $product['list'][$row]->cat_id) echo "selected=selected"; ?>><?php echo ucwords($cat['list'][$rows]->cat_name); ?></option>
<?php } ?>
</select>
</p>
</div>
<div class="col-md-6">
<input type="hidden" name="item_id" value="<?php echo $product['list'][$row]->item_id;?>">
<input type="hidden" name="image_name" value="<?php echo $product['list'][$row]->image;?>">
<h4><b>Product Name <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="item_name" value="<?php echo $product['list'][$row]->item_name;?>" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Small Description <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="small_desc" value="<?php echo $product['list'][$row]->small_desc;?>">
</p>
</div>
<div class="col-md-6">
<h4><b>Quantity<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="quantity" value="<?php echo $product['list'][$row]->quantity;?>" min="1" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Customer Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="price" value="<?php echo $product['list'][$row]->price;?>" min="1" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Reseller Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="reseller" value="<?php echo $product['list'][$row]->reseller;?>" min="1" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Color<span class="symbol"></span></b></h4>
<p>
<input class="form-control" type="text" name="color" value="<?php echo $product['list'][$row]->color;?>">
</p>
</div>
<div class="col-md-6">
<h4><b>Availability <span class="symbol required"></span></b></h4>
<select class="form-control" name="availability">
<?php if($product['list'][$row]->availability==1){;?>
<option value="1" selected>Available</option>
<option value="0">Not Available</option>
<?php } else {?>
<option value="1">Available</option>
<option value="0" selected>Not Available</option>
<?php }?>
</select>
</div>
<div class="col-md-6">
<h4><b>Status <span class="symbol required"></span></b></h4>
<select class="form-control" name="status">
<?php if($product['list'][$row]->status==0){;?>
<option value="0" selected>Inactive</option>
<option value="1">Active</option>
<?php } else {?>
<option value="0">Inactive</option>
<option value="1" selected>Active</option>
<?php }?>
</select>
</div>
<div class="col-md-6">
<h4><b>Image <span class=""></span>
</b></h4>
<input class="form-control" type="file" name="userfile">
<img src="<?php echo base_url()." assets/uploads/ ".$product['list'][$row]->image;?>" height="50px" width="50px" border="1px solid #FFF">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-light-grey">
Close
</button>
<button type="submit" class="btn btn-blue">
Update
</button>
</div>
</form>
</div>
</div>
</div>
With dynamic id, the modal will open with light black overlay on it. I can't edit the fields. Nothing is working inside the modal.
I am Not Understanding What is the problem with dynamic modal.
If Anyone knows Please reply.
You can try two things. 1. Move your form tag out and place it like this -
<form action="./admin/editProduct" enctype="multipart/form-data" method="post" autocomplete="off">
<div class="modal-body">
Give your modal z-index of 999 or so using css like this -
<style>
.modal {
z-index: 999;
}
</style>
My nav-tabs works fine using static data for my dropdown list but when I add the script to populate the dropdown list, the tabs don't work anymore.
I don't think there's any problem with the query since the list gets populated. Probably with the echo?
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active">Boarding House Info</li>
<li>Other Info</li>
<li>Location</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_1">
<div class="box-body">
<div class="form-group">
<label for="boarding-house-name">Boarding House Name</label>
<input type="text" class="form-control" id="bh-name" name="bh-name" placeholder="boarding house name">
</div>
<div class="form-group" style="margin-bottom:50px">
<label for="price">Price</label><br>
<div class="col-md-2" style="margin-left:-15px;">
<input type="text" class="form-control" id="pricemin" name="bh-pricemin" placeholder="min">
</div>
<div class="col-md-2" style="margin-left:-15px;">
<input type="text" class="form-control" id="pricemax" name="bh-pricemax" placeholder="max">
</div>
</div>
<div class="form-group">
<label for="address">Address</label>
<input type="text" class="form-control" id="address" name="bh-address" placeholder="address">
</div>
<div class="form-group">
<label for="barangay">Barangay</label>
<select class="form-control" name="bh-barangay">
<option value="Brgy 1">Brgy 1</option>
<option value="Brgy 2">Brgy 2</option>
<option value="Brgy 3">Brgy 3</option>
<option value="Brgy 4">Brgy 4</option>
</select>
</div>
<div class="form-group">
<label for="contactperson">Contact Person</label>
<input type="text" class="form-control" id="contactperson" name="bh-contactperson" placeholder="contact person">
</div>
<div class="form-group">
<label for="contactnumber">Contact Number</label>
<input type="text" class="form-control" id="contactnumber" name="bh-contactnumber" placeholder="contact number">
</div>
<div class="form-group">
<label for="owner">Owner</label>
<select class="form-control" name="bh-owner-id">
<?php
$query = "SELECT id_owner, owner_name FROM tbl_owner";
$result = $conn->query($query) or die("Connection failed: " . $conn->connect_error);
while($row = mysqli_fetch_assoc($result)) {
echo "<option value='".$row['id_owner']."'>".$row['owner_name']."</option>";
} mysql_free_result($result);
?>
</select>
</div>
</div>
</div>
<div class="tab-pane" id="tab_2">
<div class="box-body">
<div class="form-group">
<label for="tenant" style="margin-bottom:-15px;">Tenant</label>
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" id="tenant_checkbx" value="Male"> Male
</label>
<label class="checkbox-inline">
<input type="checkbox" id="tenant_checkbx" value="Female"> Female
</label>
</div>
</div>
<div class="form-group" style="margin-bottom:50px">
<label for="specification">Specification</label><br>
<div class="col-md-6" style="margin-left:-15px;">
<select class="form-control">
<option>Boarding House</option>
<option>Dormitory</option>
<option>Apartelle</option>
<option>Lodge</option>
<option>Motel</option>
</select>
</div>
</div>
<div class="form-group" style="margin-bottom:50px">
<label for="noofrooms">No. of Rooms</label><br>
<div class="col-md-6" style="margin-left:-15px;">
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="# of rooms">
</div>
</div>
<div class="col-md-2">
<div class="form-group" style="margin-left:-15px;">
<label for="curfew">Curfew</label>
<div class="radio">
<label>
<input type="radio" name="curfew_radio" id="curfew_yes" value="Yes" checked> Yes
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="curfew_radio" id="curfew_no" value="No"> No
</label>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group" style="margin-left:-15px;">
<label for="guests">Guests</label>
<div class="radio">
<label>
<input type="radio" name="guests_radio" id="guests_yes" value="Yes" checked> Yes
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="guests_radio" id="guests_no" value="No"> No
</label>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group" style="margin-left:-15px;">
<label for="crtype">CR Type</label>
<div class="checkbox">
<label>
<input type="checkbox" id="crtype_checkbx" value="Private"> Private
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="crtype_checkbx" value="Public"> Public
</label>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="tab_3">
<div class="box-body">
<!-- INSERT MAP HERE -->
</div>
</div>
</div>
</div>
Here is the query php script I used to populate the owner dropdown list:
<?php
$query = "SELECT id_owner, owner_name FROM tbl_owner";
$result = $conn->query($query) or die("Connection failed: " . $conn->connect_error);
while($row = mysqli_fetch_assoc($result)) {
echo "<option value='".$row['id_owner']."'>".$row['owner_name']."</option>";
} mysql_free_result($result);
?>
It's working now. Did some more debugging with the script and it seems like the line:
mysql_free_result($result);
(after the while condition) is the culprit.
I removed it and the tabs are working now. :)
`<div class="tab-content">
<div class="row">
<div class="col-lg-6">
<form method="post" data-toggle="modal" enctype="multipart/form-data" action="data/pegawai/proses.php">
<div class="form-group">
<label>NIP</label>
<input class="form-control" name="nip" type="text" value="<?php echo $r['nip'];?>" readonly="">
</div>
<div class="form-group">
<label>Nama Lengkap</label>
<input class="form-control" type="text" value="<?php echo $r['nm_pegawai'];?>" name="nama" placeholder="Nama Lengkap" autofocus="" required="">
</div>
<div class="form-group">
<label>Jenis Kelamin</label>
<div class="radio">
<label class="radio-inline">
<input type="radio" name="jk" id="optionsRadiosInline1" value="Laki-laki" <?php $ob->cek("Laki-laki",$r['jenis_kelamin'],"radio") ?>>Laki-laki
</label>
<label class="radio-inline">
<input type="radio" name="jk" id="optionsRadiosInline2" value="perempuan" <?php $ob->cek("Perempuan",$r['jenis_kelamin'],"radio") ?>>perempuan
</label>
</div>
</div>
<div class="form-group">
<label>Tempat Lahir</label>
<input class="form-control" type="text" value="<?php echo $r['tempat_lahir'];?>" name="tmp_lahir" placeholder="Tempat Lahir" required="">
</div>
<div class="form-group">
<label>Tanggal Lahir</label>
<input type="date" name="tgl_lahir" value="<?php echo $r['tanggal_lahir'];?>" class="form-control" placeholder="Tanggal Lahir" required="">
</div>
<div class="form-group">
<label>Agama</label>
<select class="form-control" name="agama" required="">
<option <?php $ob->cek("Islam",$r['agama'],"select") ?> value="Islam">Islam</option>
<option <?php $ob->cek("Kristen",$r['agama'],"select") ?> value="Kristen">Kristen</option>
<option <?php $ob->cek("Katholik",$r['agama'],"select") ?> value="Katholik">Katholik</option>
<option <?php $ob->cek("Protestan",$r['agama'],"select") ?> value="Protestan">Protestan</option>
<option <?php $ob->cek("Hindu",$r['agama'],"select") ?> value="Hindu">Hindu</option>
<option <?php $ob->cek("Budha",$r['agama'],"select") ?> value="Budha">Budha</option>
</select>
</div>
<div class="form-group">
<label>Alamat</label>
<textarea class="form-control" name="alamat" rows="3" placeholder="Alamat Lengkap" required=""><?php echo $r['alamat'];?></textarea>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label>Nomor Telepon</label>
<input class="form-control" type="text" value="<?php echo $r['no_telp'];?>" name="telp" onkeypress="return isNumberKey(event)" maxlength="15" placeholder="Nomor telepon" required="">
</div>
<div class="form-group">
<label>Tahun Masuk</label>
<input class="form-control" type="text" value="<?php echo $r['tahun_masuk'];?>" name="thn_masuk" placeholder="Tahun Masuk" onkeypress="return isNumberKey(event)" maxlength="4" required="">
</div>
<div class="form-group">
<label>Bagian</label>
<select class="form-control" name="bagian" required="">
<option <?php $ob->cek("Teller",$r['bagian'],"select") ?> value="Teller">Teller</option>
<option <?php $ob->cek("CSO",$r['bagian'],"select") ?> value="CSO">CSO</option>
<option <?php $ob->cek("BO",$r['bagian'],"select") ?> value="BO">BO</option>
</select>
</div>
<div class="form-group">
<label>Cabang</label>
<?php
echo '<select class="form-control" name="cabang" required="">';
$query=mysql_query("
SELECT *
FROM bank");
while($entry1=mysql_fetch_array($query))
{
echo "<option";
if($entry1['kd_bank']==$r['kd_bank']){echo " selected=selected";}
echo " value='".$entry1['kd_bank']."'>" . $entry1['nm_bank'] . "</option>";
}
echo "</select>";
?>
</div>
<div class="form-group">
<label>Kata Sandi</label>
<input class="form-control" type="password" value="<?php echo $r['password']?>" name="password" placeholder="Kata Sandi">
</div>
</div>
<!-- /.col-lg-6 (nested) -->
</div>
<!-- /.row (nested) -->
<div class="modal-footer">
<button type="button" name="ubah" class="btn btn-primary">Ubah</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</form>
</div> `
my source code, my button cannot active, how to solving it?
Thank you
Pandhu
Make your button type as "submit" like below.
<button type="submit" name="ubah" class="btn btn-primary">Ubah</button>
Else you can also keep it as button, but in that case u need to use ajax(javascript) and onclick event on button , for example :
<button type="button" name="ubah" class="btn btn-primary" onclick="save()">Ubah</button>
where save() is some function in javascript that you will create to save the form data.
I'm getting the nominee_role value from add_employee file.
In nominee_role im getting 7000 as a result, but when I'm trying to get the data value in alert it returns some html contents.
<?php
include('database.php');
include("header.php");
include("left_side_bar.php");
?>
<div class="row">
<!-- left column -->
<div class="col-xs-12">
<div class="box box-primary">
<div class="box-header">
<h3 class="box-title">
Add employee
</h3>
<?php
extract($_POST);
//echo $name;
$current_date=date("Y-m-d");
if(isset($_POST['submit']))
{
//echo "hi";
$select = "SELECT * FROM `emp_details` WHERE `branch_name` = '".$branch_code."' AND `emp_role` = '".$emp_role."' ORDER BY id DESC LIMIT 1";
//echo $select;
$exe_select=mysql_query($select);
$fetch=mysql_fetch_array($exe_select);
$rows = mysql_num_rows($exe_select);
$emp_id ='0001';
if($rows == 0)
{
$emp_id ='0001';
$emp_code=$branch_code.$emp_role.$emp_id;
//echo "employee code: ".$emp_code;
}
else
{
$emp_id=$fetch['emp_code'];
echo $emp_id;
//exit();
$emp_id= $emp_id +1;
$emp_code=$emp_id;
//echo "employee code: ".$emp_code;
}
//exit();
$sql="INSERT INTO `emp_details`
(`emp_name`, `emp_code`, `emp_role`, `dob`, `age`, `address`, `contact_number`, `gender`, `pan`, `bank_acc`, `ifsc_code`, `branch_name`,`intro_code`, `nom_name`, `nom_address`, `nom_age`, `nom_gender`, `relationship_status`, `created_date`)
VALUES
('".$name."', '".$emp_code."', '".$emp_role."', '".$dob."', '".$age."', '".$address."', '".$contact_num."', '".$gender."', '".$pan."', '".$acc_num."', '".$ifsccode."', '".$branch_code."', '".$intro_code."', '".$nom_name."', '".$nom_add."', '".$nom_age."', '".$nom_gender."', '".$rel_status."', '".$current_date."' )";
//print_r($sql);
//exit();
$exe_query=mysql_query($sql);
if($exe_query)
{
echo '<h3 class="msyqlsuccess">Employee Details Added Successfully</h3>';
}
else
{
echo '<h3 class="msyqlerror">Employee Details Not Added</h3>'; }
}
?>
</div>
</div>
<!-- form start -->
<form role="form" method="post" class="agentdetails" id="add_agent_details" enctype="multipart/form-data">
<div class="box-body clearfix">
<div class="form-group">
<label>Name</label>
<input type="text" placeholder="Enter Employee Name" id="name" required="required" name="name" class="form-control" />
</div>
<div class="form-group">
<label>DOB</label>
<input type="text" placeholder="Enter DOB" id="date_of_birth" required="required" name="dob" class="form-control" />
</div>
<div class="form-group">
<label>Age</label>
<input type="text" placeholder="Enter Employee Age" id="age" required="required" name="age" class="form-control" />
</div>
<div class="form-group">
<label>Address</label>
<input type="text" placeholder="Enter Employee Address" id="address" required="required" name="address" class="form-control" />
</div>
<div class="form-group">
<label>Contact Number</label>
<input type="text" placeholder="Enter Contact Number" id="contact_num" required="address" name="contact_num" class="form-control" />
</div>
<div class="form-group">
<label>Gender</label>
<select name="gender" id="gender" class="select">
<option value="Female">Female</option>
<option value="Male">Male</option>
</select>
</div>
<div class="form-group">
<label>Employee Role</label>
<select name="emp_role" id="" class="select">
<option value="">---Select User Role---</option>
<option value="1000">Adviser</option>
<option value="2000">Agency Manager</option>
<option value="3000">Sales Manager</option>
<option value="4000">Business Development Manager</option>
<option value="5000">Executive Manager</option>
<option value="6000">Senior Executive Manager</option>
<option value="7000">Director</option>
</select>
</div>
<div class="form-group">
<label>Branch Name</label>
<select name="branch_code" id="" class="select">
<option value="">--Select Branch--</option>
<option value="130">Chennai</option>
<option value="150">Pondicherry</option>
</select>
</div>
<div class="form-group">
<label>PAN Number</label>
<input type="text" placeholder="Enter PAN" id="pan" required="required" name="pan" class="form-control" />
</div>
<div class="form-group">
<label>Bank Account</label>
<input type="text" placeholder="Enter Bankacc" id="acc_num" required="required" name="acc_num" class="form-control" />
</div>
<div class="form-group">
<label>IFSC Code</label>
<input type="text" placeholder="Enter IFSC Code" id="ifsccode" required="required" name="ifsccode" class="form-control" />
</div>
<div class="form-group">
<label>Introducer Code</label>
<input type="text" placeholder="Enter Introducer Code" id="intro_code" required="required" name="intro_code" class="form-control" />
</div>
<div class="form-group">
<label>Nominee Role</label>
<select name="nominee_role" class="select nominee">
<option value="">---Select Nominee Role---</option>
<option value="1000">Adviser</option>
<option value="2000">Agency Manager</option>
<option value="3000">Sales Manager</option>
<option value="4000">Business Development Manager</option>
<option value="5000">Executive Manager</option>
<option value="6000">Senior Executive Manager</option>
<option value="7000">Director</option>
</select>
</div>
<div class="form-group">
<label>Nominee Name</label>
<select name="nom_name" id="" class="select nominee_name">
<option value="">---Select Nominee Role---</option>
<?php
echo $nominee_role = $_POST['nominee_role'];
//echo "hi";
//load nominee name
$get_nominee="SELECT * FROM `emp_details` WHERE `nom_role` = '".$nominee_role."'";
echo $get_nominee;
$exe_nominee=mysql_query($get_nominee);
$is_nominee=mysql_fetch_array($exe_nominee);
$nominee_row=mysql_num_rows($exe_nominee);
if($is_nominee)
{
echo '<option value="'.$is_nominee['emp_code'].'">'.$is_nominee['nom_name'].'</option>';
}
else
{
echo '<option value="">No names are found</option>';
}
?>
</select>
</div>
<div class="form-group">
<label>Nominee Age</label>
<input type="text" placeholder="Enter Nominee Age" id="nom_age" required="required" name="nom_age" class="form-control" />
</div>
<div class="form-group">
<label>Nominee Address</label>
<input type="text" placeholder="Enter Nominee Address" id="nom_add" required="required" name="nom_add" class="form-control" />
</div>
<div class="form-group">
<label>Nominee Gender</label>
<select name="nom_gender" id="" class="select">
<option value="female">Female</option>
<option value="male">Male</option>
</select>
</div>
<div class="form-group">
<label>Relationship Status</label>
<input type="text" placeholder="Enter Relationship Status" id="rel_status" required="required" name="rel_status" class="form-control" />
</div>
<div class="box-footer">
<?php //if($num){ ?>
<!-- <button class="btn btn-primary" id="next" value="Update" type="submit" name="submit" style="margin-top: 6%;">Update</button>
--> <?php //} else { ?>
<button class="btn btn-primary submit" id="add_agent_details" value="Submit" type="submit" name="submit">Submit</button>
<?php //} ?>
</div>
</div>
</form>
</div>
</div>
<?php
include("footer.php");
die;
?>
<script>
$('.nominee').change(function () {
var nominee_role = $('.nominee').val();
alert(nominee_role); // '7000'
//send nominee role
$.ajax({
type: "POST",
url: "add_employee.php",
data: {nomi_role: nominee_role},
success: function (data) {
alert(data);
}
});
return false;
});
</script>
Kindly help me to solve this! I really don't know where I leave a mistake!
Add die; at the end of add_employee.php file;
while you didnt include your add_employee file then lets say you have this in that file.
$your_var = 7000 ;
$other_value = 8000 ;
echo json_encode(array("val"=>$your_var , "val2"=>$other_value ));
then in your ajax you should have this :
$.ajax({
type: "POST",
url: "add_employee.php",
data: {nomi_role: nominee_role},
success: function (data) {
alert(data.val); //will give you 7000.
alert(data.val2); //will give you 8000.
}
});
Hope that helps .
I have an HTML form that posts to a PHP script. Everything is working except the checkbox. When it is checked, the value is not being posted.
HTML:
<input name="test" id="checkbox-02" type="checkbox" value="1" />
PHP:
if(!isset($_POST['test'])) {
$eventRepeat="No";
}
if(isset($_POST['test'])) {
$eventRepeat="Yes";
}
When this code runs, $eventRepeat always comes out as "No." I tried using the command "print_r($_POST)" and all inputs are posted except the checkbox, even when it is checked.
Any ideas what could cause this? I do have jQuery running so when it is checked two divs appear. Could that somehow be interfering? Here's the jQuery:
$(document).ready(function () {
$('#checkbox-02').change(function () {
if (!this.checked)
// ^
$('#repeatUntilDIV').fadeIn('slow');
$('#repeatFrequencyDIV').fadeIn('slow');
});
});
For reference, here is the full code:
<form class="cmxform form-horizontal tasi-form" id="commentForm" role="form" action="" method="post">
<div class="form-group">
<label for="inputEventTitle" class="col-lg-2 control-label">Event Title</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventTitle" placeholder="Event Title" required>
</div>
</div>
<div class="form-group">
<label for="inputEventDescription" class="col-lg-2 control-label">Description</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventDescription" placeholder="Event Description" required>
</div>
</div>
<div class="form-group">
<label for="inputEventStartTime" class="col-lg-2 control-label">Start Time</label>
<div class="col-lg-10">
<select name="inputEventStartTime" class="form-control" id="dp1" required>
<option label="Start Time">
<option value="12:00AM">12:00AM</option>
<option value="12:15AM">12:15AM</option>
<option value="12:30AM">12:30AM</option>
<option value="12:45AM">12:45AM</option>
<option value="1:00AM">1:00AM</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputEventEndTime" class="col-lg-2 control-label">End Time</label>
<div class="col-lg-10">
<select name="inputEventEndTime" class="form-control" id="dp1" required>
<option label="End Time">
<option value="1:00AM">1:00AM</option>
<option value="1:15AM">1:15AM</option>
<option value="1:30AM">1:30AM</option>
<option value="1:45AM">1:45AM</option>
<option value="2:00AM">2:00AM</option>
</select> </div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Date</label>
<div class="col-sm-6">
<input id="dp1" name="inputEventDate" type="text" size="16" class="form-control" required>
</div>
</div>
<div class="form-group">
<label for="inputEventDate" class="col-lg-2 control-label">Repeat?</label>
<div class="col-lg-10 checkboxes">
<label class="label_check" for="checkbox-02"> </label>
<input name="test" id="checkbox-02" type="checkbox" value="1" /> Yes, I want to repeat this event.
</div>
</div>
<div class="form-group" id="repeatUntilDIV" style="display:none;">
<label for="inputEventEndDate" class="col-lg-2 control-label">Repeat Until</label>
<div class="col-lg-10">
<input name="inputEventEndDate" id="eventEndDate" type="text" placeholder="End Date" class="form-control">
</div>
</div>
<div class="form-group" id="repeatFrequencyDIV" style="display:none;">
<label for="inputEventFrequency" class="col-lg-2 control-label">Repeat Every</label>
<div class="col-lg-10">
<select name="inputEventFrequency" class="form-control" id="dp1">
<option label="Repeat Every">
<option value="1">Repeat Every Day</option>
<option value="2">Repeat Every Other Day</option>
<option value="7">Repeat Every Week</option>
<option value="14">Repeat Every Other Week</option>
<option value="30">Repeat Every Month</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
<input type="submit" name="addPrimaryEvent" class="btn btn-success" value="Submit" />
</form>
I get this from var_dump($_POST):
array(8) {
["inputEventTitle"]=>
string(5) "Title"
["inputEventDescription"]=>
string(11) "Description"
["inputEventStartTime"]=>
string(6) "2:00AM"
["inputEventEndTime"]=>
string(6) "3:00AM"
["inputEventDate"]=>
string(10) "05-26-2014"
["inputEventEndDate"]=>
string(10) "05-29-2014"
["inputEventFrequency"]=>
string(1) "1"
["addPrimaryEvent"]=>
string(6) "Submit"
}
Very unclear why this would not work. But I noticed inconsistencies & imbalance in the HTML tags as well as an empty action="" which is not HTML5 valid. For more details, see this great answer over here.
So I have set it to #. You might want to actually change that to the full filename or path to the PHP script such as action="form.php". Or you could leave it out altogether like this:
<form class="cmxform form-horizontal tasi-form" id="commentForm" role="form" action="#" method="post">
But I prefer to be explicit & recommend the action="form.php" way of handling things. Here is your cleaned up HTML form:
<form class="cmxform form-horizontal tasi-form" id="commentForm" role="form" action="#" method="post">
<div class="form-group">
<label for="inputEventTitle" class="col-lg-2 control-label">Event Title</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventTitle" placeholder="Event Title" required="" />
</div>
</div>
<div class="form-group">
<label for="inputEventDescription" class="col-lg-2 control-label">Description</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventDescription" placeholder="Event Description" required="" />
</div>
</div>
<div class="form-group">
<label for="inputEventStartTime" class="col-lg-2 control-label">Start Time</label>
<div class="col-lg-10">
<select name="inputEventStartTime" class="form-control" id="dp1" required="">
<option value="12:00AM">
12:00AM
</option>
<option value="12:15AM">
12:15AM
</option>
<option value="12:30AM">
12:30AM
</option>
<option value="12:45AM">
12:45AM
</option>
<option value="1:00AM">
1:00AM
</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputEventEndTime" class="col-lg-2 control-label">End Time</label>
<div class="col-lg-10">
<select name="inputEventEndTime" class="form-control" id="dp1" required="">
<option value="1:00AM">
1:00AM
</option>
<option value="1:15AM">
1:15AM
</option>
<option value="1:30AM">
1:30AM
</option>
<option value="1:45AM">
1:45AM
</option>
<option value="2:00AM">
2:00AM
</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Date</label>
<div class="col-sm-6">
<input id="dp1" name="inputEventDate" type="text" size="16" class="form-control" required="" />
</div>
</div>
<div class="form-group">
<label for="inputEventDate" class="col-lg-2 control-label">Repeat?</label>
<div class="col-lg-10 checkboxes">
<input name="test" id="checkbox-02" type="checkbox" value="1" /> Yes, I want to repeat this event.
</div>
</div>
<div class="form-group" id="repeatUntilDIV" style="display:none;">
<label for="inputEventEndDate" class="col-lg-2 control-label">Repeat Until</label>
<div class="col-lg-10">
<input name="inputEventEndDate" id="eventEndDate" type="text" placeholder="End Date" class="form-control" />
</div>
</div>
<div class="form-group" id="repeatFrequencyDIV" style="display:none;">
<label for="inputEventFrequency" class="col-lg-2 control-label">Repeat Every</label>
<div class="col-lg-10">
<select name="inputEventFrequency" class="form-control" id="dp1">
<option value="1">
Repeat Every Day
</option>
<option value="2">
Repeat Every Other Day
</option>
<option value="7">
Repeat Every Week
</option>
<option value="14">
Repeat Every Other Week
</option>
<option value="30">
Repeat Every Month
</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button> <input type="submit" name="addPrimaryEvent" class="btn btn-success" value="Submit" />
</div>
</form>