I am trying to do a cubic calculator program where the calculated cubic meter is always added to the result of the previous calculation and displayed. I'm trying to do it with SESSION but it doesn't work out. When I start the calculation it does not show the value. How can I store the previous calculation and add it to the new one?
<?php
session_start();
include 'settings.php';
$title = 'Főoldal';
require_once 'components/htmltop.php';
require_once 'components/navbar.php';
if(isset($_POST["add_to_cart"]))
{
if(isset($_SESSION["cubic_cart"]))
{
$item_array = array(
'item_width' => $_POST["width"],
'item_length' => $_POST["length"],
'item_thickness' => $_POST["thickness"]
);
$_SESSION["cubic_cart"][0] = $item_array;
}
}
?>
<div class="col container text-center">
<div class="row">
<div class="col-sm">
<div class="container">
<form action="" method="post" class="col mx-auto mb-2 form-group p-3 text-center">
<div class="form-group col-md">
<input id="textBar" type="text" name="width" value="" class="i1 form-control mb-3 mx-auto" autocomplete="off" required>
</div>
<div class="row">
<div class="form-group col-md-6">
<select type="text" name="length" value="" class="s2 form-control mb-3 mx-auto" required>
<option selected>Length</option>
<option value="2.5">2.5</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
<div class="form-group col-md-6">
<select type="text" name="thickness" value="" class="s2 form-control mb-3 mx-auto" required>
<option selected>Thickness</option>
<option value="0.029">29</option>
<option value="0.031">31</option>
</select>
</div>
</div>
<button type="submit" name="add_to_cart" class="btn btn-lg btn-success" onclick="return confirm('Biztos rögzíteni szeretné?')">Calculate</button>
</form>
</div>
<div id="clockDisplay" class="container mb-2"></div>
<div claas="container">
<div class="row">
<div class="napi col-md-6 mt-3">
<?php
if(!empty($_SESSION["cubic_cart"]))
{
$total = 0;
foreach($_SESSION["cubic_cart"] as $keys => $values)
{
?>
<?php
$total = $total + ($values["item_width"] * $values["item_length"]* $values["item_thickness"]);
}
?>
?>
<h3>Total: </h3>
<h2><?php echo number_format($total, 4); ?> m3</h2>
<?php
}
?>
</div>
</div>
</div>
Related
I am using Metronic Form Repeater in our project.
My form tag doesn't have any encryption or content type.
<form class="m-form" action="<?php echo $action; ?>" method='POST'></form>
When I submit the form, I can see our data like below
Unfortunately, when I print the $_POST, I see an empty array.
Form Code
<div class="form-group m-form__group row" id="m_repeater_1">
<div data-repeater-list="" class="col-lg-12">
<div data-repeater-item class="form-group m-form__group row align-items-center">
<div class="col-md-3">
<div class="m-form__group m-form__group--inline">
<div class="m-form__label">
<label>Column Name</label>
</div>
<div class="m-form__control">
<input type="name" name="col_name" class="form-control m-input" placeholder="Enter full name">
</div>
</div>
<div class="d-md-none m--margin-bottom-10"></div>
</div>
<div class="col-md-4">
<div class="m-form__group m-form__group--inline">
<div class="form-group m-form__group row">
<label class="col-form-label col-lg-3 col-sm-12">Data Type</label>
<div class="col-lg-6 col-md-9 col-sm-6">
<select class="form-control m-select2" id="m_select2_1" name="param">
<option value='TINYINT'>TINYINT</option>
<option value='SMALLINT'>SMALLINT</option>
<option value='MEDIUMINT'>MEDIUMINT</option>
</select>
</div>
</div>
</div>
<div class="d-md-none m--margin-bottom-10"></div>
</div>
<div class="col-md-3">
<div class="m-form__group m-form__group--inline">
<div class="m-form__label">
<label>Length</label>
</div>
<div class="m-form__control">
<input type="number" name="col_long" class="form-control m-input" placeholder="Uzunluk Giriniz">
</div>
</div>
<div class="d-md-none m--margin-bottom-10"></div>
</div>
<div class="form-group m-form__group col-md-3">
<label for="exampleSelect1">Default</label>
<select class="form-control m-input" id="exampleSelect1" name="col_def">
<option value='1'>NoDefault</option>
<option value='2'>NULL</option>
<option value='3'>CURRENT_TIMESTAMP</option>
<option value='4'>ON UPDATE CURRENT_TIMESTAMP</option>
<option value='5'>AUTO_INCREMENT</option>
</select>
</div>
</div>
</div>
</div>
i have a php form, that adds a 'review' to a 'guide' in an SQL database.
i finally figured out my problem, and it is when i use copy paste in the input areas.
what can cause this??
any help appreciated!!
this is the link
this is my code:
<body >
<form class="form-horizontal" method="POST" >
<div class="form-group" >
<div class="col-sm-1">
<a href="." > <img src="Pictures/Design/בחזרה לאתר.png" height="100" width="100"/> </a>
</div>
<div class="col-sm-10">
<h2>הוספת ביקורת ל: <?php if(isset($_SESSION ['name'])){echo $_SESSION ['name'];} else {echo $gname;}?></label>
</h2>
</div>
</div>
<hr>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-4 " align="right">
<?php $val="uploads/guides/".$row['Picture'];?>
<image src='<?php echo $val;?>' height="130px" width="100px">
</div>
<div class="col-sm-7 " align="right">
<div><label class=" control-label" ><?php if(isset($_SESSION ['name'])){echo $_SESSION ['name'];} else {echo $gname;}?></label><label class=" control-label" >   :שם המדריך</label></div>
<div><label class=" control-label" ><?php if(isset($_SESSION ['attraction'])){echo $_SESSION ['attraction'];} else {echo $gattraction;}?></label><label class=" control-label" >   :אטרקציה</label></div>
<div><label class=" control-label" ><?php if(isset($_SESSION ['email'])){echo $_SESSION ['email'];} else {echo $gemail;}?></label><label class=" control-label" >   :אימייל</label></div>
<div><label class=" control-label" ><?php if(isset($_SESSION ['phone'])){echo $_SESSION ['phone'];} else {echo $gphone;}?></label><label class=" control-label" >   :טלפון</label></div>
</div>
</div>
</div>
<hr>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >שמך המלא</label>
</div>
<div class="col-sm-12">
<input type="text" class="form-control" name="name" placeholder="" />
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >מתי השתמשת בשירותי המדריך</label>
</div>
<div class="col-sm-6 " align="right">
<select class="form-control" name="year">
<option value="בחר/י שנה">בחר/י שנה</option>
<option value="2016">2016</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
</select>
</div>
<div class="col-sm-6 " align="right">
<select class="form-control" name="month">
<option value="בחר/י חודש">בחר/י חודש</option>
<option value="ינואר">ינואר</option>
<option value="פברואר">פברואר</option>
<option value="מרץ">מרץ</option>
<option value="אפריל">אפריל</option>
<option value="מאי">מאי</option>
<option value="יוני">יוני</option>
<option value="יולי">יולי</option>
<option value="אוגוסט">אוגוסט</option>
<option value="ספטמבר">ספטמבר</option>
<option value="אוקטובר">אוקטובר</option>
<option value="נובמבר">נובמבר</option>
<option value="דצמבר">דצמבר</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >ציון 1-5</label>
</div>
<div class="col-sm-3 col-sm-offset-9 " align="right">
<select class="form-control " name="rating">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >כמה שילמת ומה זה כלל</label>
</div>
<div class="col-sm-12">
<textarea class="form-control" name="pay" cols="40" rows="2"></textarea>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >פרטו את חוויתכם עם המדריך בהרחבה</label>
</div>
<div class="col-sm-12">
<textarea class="form-control" name="exp" cols="40" rows="5" required></textarea>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
</div>
</div>
<div class="form-group" >
<div class="col-sm-12 col-sm-offset-5"><button type="submit" class="btn btn-primary btn-sm" name="addreview" value="Submit Record">הוספת ביקורת</button></div>
</div>
<?php
if(isset($_POST['addreview'])){
$name = $_POST['name'];
$name = str_replace("'","''",$name);
$monthh = $_POST['month'];
$yearr = $_POST['year'];
$pay = $_POST['pay'];
$pay = str_replace("'","''",$pay);
$exp= $_POST['exp'];
$exp = str_replace("'","''",$exp);
$rating=$_POST['rating'];
$query1="INSERT INTO review (ReviewerName,ServiceMonth,ServiceYear,Rating,Payment,Experience,Guide_ID) VALUES ";
$query1.="('$name','$monthh','$yearr','$rating','$pay','$exp','$guideid')";
$result=mysqli_query($conn,$query1);
if($result){
?>
<script type="text/javascript">
window.location = "./review_added_successfully.php";
</script>
<?php
}
else{
echo "not submitted";
}
} ?>
</form>
</body>
here my html code.
i want fetch data from database. when a user search profile then i want display only searched data which enter in form.
the problem is query doesn't work. can you tell me can we run multiple query in single query.
<form method="get" action="search.php" enctype="multipart/form-data">
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Gender : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<select name="gender">
<option value="">Select Gender</option>
<option value="">Male</option>
<option value="">Female</option>
</select>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Marital Status : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<select name="mstatus">
<option>Select status</option>
<option value="Single">Single</option>
<option value="Married">Married</option>
<option value="Widow">Widow</option>
<option value="Widower">Widower</option>
<option value="Divorcee">Divorcee</option>
<option value="Seprated">Seprated</option>
</select>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Gotra : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<select name="gotra">
<option>Select gotra</option>
<option value="Aalakuntor">Aalakuntor</option>
<option value="Bantalor">Bantalor</option>
<option value="Batalor">Batalor</option>
<option value="Bayamuttalor">Bayamuttalor</option>
</select>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">District / City : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<input type="text" class="form-control" placeholder="city" name="city" >
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Education : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<input type="text" class="form-control" placeholder="education" name="education" >
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Age : </label>
<div class="col-sm-7 form_radios">
<div class="col-sm-5 input-group1">
<input class="form-control has-dark-background" name="age1" id="slider-name" placeholder="28" type="text" >
</div>
<div class="col-sm-5 input-group1">
<input class="form-control has-dark-background" name="age2" id="slider-name" placeholder="40" type="text" >
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<div class="col-sm-5 input-group1">
<div class="select-block1">
<input type="submit" class="btn btn-success" value="Search" name="search">
</div>
</div>
<div class="clearfix"> </div>
</div>
</form>
here my search.php code.
<div class="paid_people">
<h1></h1>
<div class="row_1">
<?php
include("includes/db.php");
global $con;
if(isset($_GET['search']))
{
$search_gender = $_GET['gender'];
$search_mstatus = $_GET['mstatus'];
$search_gotra = $_GET['gotra'];
$search_city = $_GET['city'];
$search_education = $_GET['education'];
$search_age1 = $_GET['age1'];
$search_age2 = $_GET['age2'];
$get_user = "SELECT * FROM users WHERE age BETWEEN '$search_age1' AND '$search_age2' AND gender like '$search_gender' AND mstatus like '$search_mstatus' AND gotra like '$search_gotra' AND education like '$search_education' AND city like'$search_city'";
$run_user = mysqli_query($con, $get_user);
while ($row_user = mysqli_fetch_array($run_user))
{
$u_id = $row_user['user_id'];
$u_fname = $row_user['first_name'];
$u_age = $row_user['age'];
$u_education = $row_user['education'];
$u_occupation = $row_user['occupation'];
$u_city = $row_user['city'];
$u_image = $row_user['photo'];
$profile_id = $row_user['profile_id'];
echo "<div class='col-sm-6 paid_people-left'>
<ul class='profile_item'>
<a href='view_profile.php?userdetail_id=$u_id'>
<li class='profile_item-img'>
<img src='admin_vadarshadi/users-photo/resized_$u_image' class='img-responsive' alt='$u_fname' />
</li>
<li class='profile_item-desc'>
<h4>Profile ID: $profile_id</h4>
<h4>Name: $u_fname Age: $u_age Yrs </h4>
<p>City: $u_city, Education: $u_education</p>
<h5>View Full Profile</h5>
</li>
<div class='clearfix'> </div>
</a>
</ul>
</div>";
}
}
?>
</div>
</div>
I am uploading images to "images" directory and some info to my database in codeigniter. But when I click to submit button after completing form, It posts nothing. It gives error that there is not posted any input(not the same as error message just meaning). If someone could please look over this code, and tell me why it's not working. Thank you in advance. Here my controller code:
<?php
public function create()
{
// image1
$ImageName = $_FILES['image']['name'];
$imageSize= $_FILES['image']['size'];
$imageSource = $_FILES['image']['tmp_name'];
move_uploaded_file($_FILES['image']['tmp_name'], "images/$ImageName");
$this->create_thumb($ImageName);
$this->compress($ImageName, $imageSize, "images/$ImageName");
// image2
if ($this->input->post('image2'))
{
$ImageName2 = $_FILES['image2']['name'];
$imageSize2= $_FILES['image2']['size'];
$imageSource2 = $_FILES['image2']['tmp_name'];
$this->compress($ImageName2, $imageSize2, $imageSource2);
}
// image3
if ($this->input->post('image3'))
{
$ImageName3 = $_FILES['image3']['name'];
$imageSize3= $_FILES['image3']['size'];
$imageSource3 = $_FILES['image3']['tmp_name'];
$this->compress($ImageName3, $imageSize3, $imageSource3);
}
// image4
if ($this->input->post('image4'))
{
$ImageName4 = $_FILES['image4']['name'];
$imageSize4= $_FILES['image4']['size'];
$imageSource4 = $_FILES['image4']['tmp_name'];
$this->compress($ImageName4, $imageSize4, $imageSource4);
}
$this->news_model->set_news();
$this->load->view('News/success');
}
?>
Here my view code:
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="content">
<form action="<?php echo base_url();?>index.php/news/create/" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label>Сарлавха:</label>
<input type="text" name="title" class="form-control" placeholder="Сарлавха">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Автомобил тури:</label>
<select name="category" class="form-control">
<option value="yuk">Юк</option>
<option value="kichik">Кичик тижорат</option>
<option value="yengil">Енгил</option>
<option value="maxsus">Махсус техника</option>
<option value="tyagach">Тягач</option>
<option value="prisep">Прицеп</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Нархи:</label>
<input type="number" name="price" class="form-control" placeholder="Нархи">
</div>
</div>
<div class="col-md-8">
<div class="form-group">
<label>Исми ва шарифи:</label>
<input type="text" name="name" class="form-control" placeholder="Исми ва шарифи">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Телефон рақам:</label>
<input type="text" name="telno" class="form-control" value="+998" placeholder="Телефон рақам">
</div>
</div>
<div class="col-md-8">
<div class="form-group">
<label>Жойи:</label>
<select name="location" class="form-control">
<option value="Қорақалпоғистон Республикаси">Қорақалпоғистон Республикаси</option>
<option value="Бухоро вилояти">Бухоро вилояти</option>
<option value="Жиззах вилояти">Жиззах вилояти</option>
<option value="Қашқадарё вилояти">Қашқадарё вилояти</option>
<option value="Навоий вилояти">Навоий вилояти</option>
<option value="Наманган вилояти">Наманган вилояти</option>
<option value="Сурхондарё вилояти">Сурхондарё вилояти</option>
<option value="Сирдарё вилояти">Сирдарё вилояти</option>
<option value="Тошкент вилояти">Тошкент вилояти</option>
<option value="Фарғона вилояти">Фарғона вилояти</option>
<option value="Хоразм вилояти">Хоразм вилояти</option>
<option value="Тошкент шаҳар">Тошкент шаҳар</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Қўшимча маълумот:</label>
<textarea rows="5" name="info" class="form-control" placeholder="Қўшимча маълумот" ></textarea>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Асосий расмни танланг:</label>
<input type="file" name='image' class="form-control" accept="image/*" >
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Қўшимча расмни танланг:</label>
<input type="file" name='image2' class="form-control" accept="image/*" >
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Қўшимча расмни танланг:</label>
<input type="file" name='image3' class="form-control" accept="image/*" >
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Қўшимча расмни танланг:</label>
<input type="file" name='image4' class="form-control" accept="image/*" >
</div>
</div>
</div>
<button type="submit" class="btn btn-info btn-fill pull-right" name="submit" value="submit">Юклаш</button>
<div class="clearfix" ></div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
Try this for debug first check $_FILES having any data.
print_r($_FILES);
If it has any data then trying to change condition like. Instead
if ($this->input->post('image2')){
Use following
if( isset( $_FILES['image']['name']) and $_FILES['image']['name'] != '' ) {
// Your code
}
Your Controller Should Be Like This
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Controller_name extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->model('your_model');
$this->load->library('upload');
}
public function function_name(){
if($this->input->post('submit')){
/* Your Function */
}
OR Use
if($_POST){
/* Your Function */
}
$this->load->view('News/success');
}
Controller Name Should Be Start From Capital Letter
The if ($this->input->post('image3')){ /* ... */ } is wrong. PHP will not see uploaded files.Check them as : if (array_key_exists($_FILES, 'image3')){ /* ... */ }
I have total 7 Id in MySQL table. and I am fetching those Id's from database
code is :
<form class="form-inline" method="POST" action="book.php">
<div class="row-fluid home">
<div class="span3">
<?php
$query=mysql_query("select * from category");
$cat_count = 0;
while($result=mysql_fetch_array($query))
{
$category_id=$result['cat_id'];
$category_type=$result['cat_type'];
$categroy_desc=$result['cat_desc'];
$category_image=$result['cat_images'];
$category_price=$result['cat_price'];
$cat_count += 1;
//$_SESSION["session_category_id"] = $category_id;
?>
<div class="room_selector" data-price="<?php echo $category_price; ?>" data-adults="4" data-kids="2"
<?php if ($cat_count!=1) {echo 'style="display: none;"'; } ?> >
<h5>
<a href="index.php?id=<?php echo $category_id; ?>" class="pull-left">
<i class="icon-chevron-left"></i>
</a>
<?php echo $category_type; ?>
<a href="index.php?id=<?php echo $category_id; ?>" class="pull-right ">
<i class="icon-chevron-right"></i>
</a>
</h5>
<a class="iframe" href="rooms.php">
<img src="data:image/png;base64,<?php echo base64_encode($category_image); ?>" alt="No Photo" />
</a>
<p><?php echo $categroy_desc;?></p><br><Br><bR>
<!--<a class="btn btn-primary btn-large book-now" name="submit" type="submit" href="book.php?id=<?php echo $category_id; ?>">
Check Availability!</a>-->
<?php echo $x=$category_id;
?>
<input type="hidden" name="cat_id" value="<?php echo $category_id; ?>">
<?php $users[] = $result['cat_id'];?>
</div>
<?php
}
?>
<?php echo $category_id;
?>
</div>
<div class="span3 home_calendar">
<div class="form-horizontal">
<div class="control-group">
<label class="control-label pull-left" for="inputEmail">Arrive</label>
<div class="controls">
<input type="text" value="" name="from" class="span2 check-in-date" value="2015/05/22" />
</div>
</div>
</div>
<div class="datepicker_from"></div>
</div>
<div class="span3 home_calendar">
<div class="form-horizontal">
<div class="control-group">
<label class="control-label pull-left" for="inputEmail">Depart</label>
<div class="controls">
<input type="text" value="" name="to" class="span2 check-out-date" value="2015/05/27" />
</div>
</div>
</div>
<div class="datepicker_to"></div>
</div>
<div class="span3">
<div class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputEmail">Rooms</label>
<div class="controls">
<select class="span1 select_rooms" name="no_of_selected_room">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">Adults per room</label>
<div class="controls">
<select class="span1 select_adults" name="no_of_adults">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">Kids per room</label>
<div class="controls">
<select class="span1 select_kids" name="no_of_kids">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">extra person</label>
<div class="controls">
<select class="span1 select_kids">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
</div>
</div>
<div id="total_price" class="price" name="price"></div>
<input type="submit" class="btn btn-primary btn-large book-now" name="submit" value="Check Availability!">
<!--<a class="btn btn-primary btn-large book-now" type="submit" href="book.php?id=">Check Availability!</a>-->
</div>
The $category_id is the main key to my project. once user will select the room then the $category_id will select based on that.
I am trying to send this id to other page using one form
//book.php
if(isset($_POST['submit']))
{
$n_cat_from = $_POST['from'];
$n_cat_to = $_POST['to'];
$n_no_of_selected_rooms = $_POST['no_of_selected_room'];
$n_no_of_adults = $_POST['no_of_adults'];
$n_no_of_kids = $_POST['no_of_kids'];
$current_Category_id = $_POST['cat_id'];
echo "id;;;;;;;;;;;;" . $current_Category_id;
}
?>
When I try to echo that id I am getting only last id in the database (after user selecting different id also )
where I am wrong ? why it is taking last Id ? help me
if you want to store multiple values in a hidden input with the same name, you have to add [] after the name, like this:
<input type="hidden" name="cat_id[]" value="<?php echo $category_id; ?>">
<?php $users[] = $result['cat_id'];?>
this way, you should have an array in book.php:
$_POST[cat_id] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 )