Here I want to change the UI design of this code.I need to display the belows are in table view.Here in code some fields have same names that is name ml,name en and info ml,info en and details ml,details en.that two similer fields should be in same line
<div class="form quick-post">
<!-- Edit deity Details-->
<form class="form-horizontal" action="deity_manage.php" method="post">
<!-- Deity id -->
<div class="form-group">
<label class="control-label col-lg-2" for="title"></label>
<div class="col-lg-10">
<input type="hidden" class="form-control" name="deity_id" id="title" value="<?php echo $deity_id;?>">
</div>
</div>
<!-- Name ml -->
<label class="control-label col-lg-2" for="title">Name Ml</label>
<input type="text" class="form-control" name="deity_name_ml" id="deity_name_ml" value="<?php echo $deity_name_ml;?>">
<!--Name en-->
<label class="control-label col-lg-2" for="content">Name En</label>
<input type="text" class="form-control" name="deity_name_en" id="deity_name_en" value="<?php echo $deity_name_en; ?>">
<div style="padding-top:25px"></div>
<!--Info ml-->
<label class="control-label col-lg-2" for="content">Info Ml</label>
<textarea rows="4" cols="50" name="info_ml" ><?php echo $info_ml;?></textarea>
<!--Info en-->
<label class="control-label col-lg-2" for="content">Info En</label>
<textarea rows="4" cols="50" name="info_en" ><?php echo $info_en;?></textarea>
<div style="padding-top:25px"></div>
<!--details_ml -->
<label class="control-label col-lg-2" for="content">Details Ml</label>
<textarea rows="4" cols="50" name="details_ml" ><?php echo $details_ml;?></textarea>
<!--Details en-->
<label class="control-label col-lg-2" for="content">Details En</label>
<textarea rows="4" cols="50" name="details_en" ><?php echo $details_en;?></textarea>
<div style="padding-top:25px"></div>
<!--Mantra ml-->
<label class="control-label col-lg-2" for="content">Mantra Ml</label>
<input type="text" class="form-control" name="mantra_ml" id="mantra_ml" value="<?php echo $mantra_ml;?>">
<!--Mantra en-->
<label class="control-label col-lg-2" for="content">Mantra En</label>
<input type="text" class="form-control" name="mantra_en" id="mantra_en" value="<?php echo $mantra_en;?>">
<div style="padding-top:25px"></div>
<!--God-->
<label class="control-label col-lg-2" for="content">God</label>
<select multiple="true" name="god_id">
<?php while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<option <?php if($row['god_id'] == $god_id) { echo "selected='selected'"; } ?> value="<?php echo $row['god_id'];?>">
<?php echo $row['god_name_en']; ?>
</option>
<?php } ?>
</option>
</select>
<div style="padding-top:25px"></div>
<!--Display order-->
<label class="control-label col-lg-2" for="content">Display Order</label>
<input type="text" class="form-control" name="display_order" id="display_order" value="<?php echo $display_order;?>">
<div style="padding-top:25px"></div>
<!-- Buttons -->
<div class="form-group">
<!-- Buttons -->
<div class="col-lg-offset-2 col-lg-9">
<button type="submit" class="btn btn-danger" name="submit" value="submit"> Save </button>
</div>
</div>
</form>
</div>
</div>
Give all the labels and input types inside the tag
<table>
<tr>
<td><label class="control-label col-lg-2" for="content">Details En</label>
</td>
<td>
<textarea rows="4" cols="50" name="details_en" ><?php echo $details_en;?></textarea>
</td>
<Label
Related
This is my PHP code, which will display data when I click the button. I want to display the data for the specified card when I click the button for the number 1. I want to display all information in card 1, but my code will display all information. Can anyone help me?
http://www.m9c.net/uploads/15678158911.png
<? $title= 'Show CV';
$quariy = ("select * from information where selector ='2'");
$result = mysqli_query($mysqli, $quariy) or die("database
error:". mysqli_error($mysqli));
while ($data = mysqli_fetch_assoc($result)) {?>
<form action="" method = "post" class= "pl-4 pr-4">
<div class="card">
<div class="card-body">
<div class="form-group">
<label for="name">Your Name</label>
<input type="text" class="form-control" name="name"
value="<?php echo $data['name'] ?>">
</div>
<div class="form-group">
<label for="education">Your Education</label>
<input type="text" class="form-control"
name="education" value="<?php echo $data['education']?>" >
</div>
<div class="form-group">
<label for="contact_information"> Contact
Information </label>
<textarea class="form-control"
name="contact_information" rows="3"><?php echo
$data['contact_information'] ?></textarea></div>
<div class="form-group">
<label for="skills">Skills</label>
<textarea class="form-control" name="skills"
rows="3"><?php echo $data['skills'] ?></textarea>
</div>
<div class="form-group">
<label for="work">Work Experiences </label>
<textarea class="form-control" name="work"
rows="3">
<?php echo $data['work'] ?></textarea></div>
<div class="form-group">
<label for="projects">Projects </label>
<textarea class="form-control" name="projects"
rows="3"><?php echo $data['projects'] ?>
</textarea>
</div></div><?php }?></form>
`<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 have a form to inject data in a database. When user clicks submit button this error shows up in a <input type=text>field. I have been looking around for a solution for hours but I do not know how to fix this.
Warning: htmlentities() expects parameter 1 to be
string, array given in
C:rr\xampp\htdocs\ecommerce\helpers\helpers.php on line
11
helpers.php
<?php
function display_errors($errors){
$display = ' <ul class="bg-danger">';
foreach($errors as $error){
$display .='<li class="text-danger">'.$error. '</li> ';
}
$display .='</ul>';
return $display;
}
function sanitize ($dirty){
return htmlentities($dirty, ENT_QUOTES, "UTF-8");
}
function money($number){
return '$ '.number_format($number,2);
}
form.php
<form action="products.php?add=1" method="POST" enctype="multipart/form-data">
<div class='container_12'>
<div class="form-group col-md-3">
<label for="prod_name">Product Name*:</label>
<input type="text" name="prod_name" id="prod_name" class="form-control" value="<?=((isset($_POST['prod_name']))?sanitize($_POST):' ');?>">
</div>
<div class="form-group col-md-3">
<label for="parent">Parent Category*:</label>
<select class="form-control" id="parent" name="parent">
<option value=""<?=((isset($_POST['parent']) && $_POST['parent'] == '')?'selected':'');?>></option>
<?php while($parent = mysqli_fetch_assoc($parentQuery)): ?>
<option value=" <?=$parent['id'];?>"<?=((isset($_POST['parent']) && $_POST['parent'] == $parent['id'])?' select':'');?>><?=$parent['category_name'];?></option>
<?php endwhile; ?>
</select>
</div>
<div class='form-group col-md-3'>
<label for='child'>Second Category*:</label>
<select id='child' name='child' class='form-control'></select>
</div>
</div>
<div class='container_12'>
<div class='form-group col-md-3'>
<label for='list_price'>List Price(OPTIONAL): </label>
<input type="text" id="list_price" name="list_price" class="form-control" value="<?=((isset($_POST['list_price']))?sanitize($_POST['list_price']):'');?>">
</div>
<div class="form-group col-md-3">
<label for="price">Price*:</label>
<input type="text" id="price" name="price" class="form-control" value="<?=((isset($_POST['price']))?sanitize($_POST['price']):'');?>">
</div>
<div class='form-group col-md-3'>
<label for='prod_width'>Width* (in inches):</label>
<input type="text" id="prod_width" name="prod_width" class="form-control" value="<?=((isset($_POST['prod_width']))?sanitize($_POST['prod_width']):'');?>">
</div>
<div class='form-group col-md-3'>
<label for='prod_depth'>Height*(in inches):</label>
<input type="text" id="'prod_depth" name="'prod_depth" class="form-control" value="<?=((isset($_POST['prod_depth']))?sanitize($_POST['prod_depth']):'');?>">
</div>
</div>
<div class='container_12'>
<div class='form-group col-md-3'>
<label for='prod_height'>Depth*(in inches):</label>
<input type="text" id="prod_height" name="prod_height" class="form-control" value="<?=((isset($_POST['prod_height']))?sanitize($_POST['prod_height']):'');?>">
</div>
<div class='form-group col-md-3'>
<label for='prod_material'>Construction Material:</label>
<input type="text" id="prod_material" name="prod_material" class="form-control" value="<?=((isset($_POST['prod_material']))?sanitize($_POST['prod_material']):'');?>">
</div>
<div class='form-group col-md-6'>
<label>Quantity * :</label>
<input type="text" id="quantity" name="quantity" class="form-control" value="<?=((isset($_POST['quantity']))?sanitize($_POST['quantity']):'');?>">
</div>
</div>
<div class='container_12'>
<div class="form-group col-md-3"> <label for="image_1">Product Photo #1:</label>
<input type="file" name="image_1" id="image_1" class="form-control">
</div>
<div class="form-group col-md-3"> <label for="image_2">Product Photo #2:</label>
<input type="file" name="image_2" id="image_2" class="form-control">
</div>
<div class="form-group col-md-3"> <label for="image_3">Product Photo #3:</label>
<input type="file" name="image_3" id="image_3" class="form-control">
</div>
<div class="form-group col-md-3"> <label for="image_4">Product Photo#4:</label>
<input type="file" name="image_4" id="image_4" class="form-control">
</div>
</div>
<div class='container_12'>
<div class="form-group col-md-6">
<label for="description">Description:</label>
<textarea id="description" name="description" class="form-control" rows="6"><?=((isset($_POST['description']))?sanitize($_POST['description']):'');?></textarea>
</div>
<div class="form-group col-md-6">
<label for="care_instructions">Care Instructions*:</label>
<textarea id="care_instructions" name="care_instructions" class="form-control" rows="6"><?=((isset($_POST['care_instructions']))?sanitize($_POST['care_instructions']):'');?></textarea>
</div></div>
<div class='container_12'>
<div class="form-group pull-right">
<input type='submit' value='Add Product' class='form-control btn-success pull-right'>
</div></div>
</form>
You are passing the whole $_POST variable to serialize in the product name input (that's why the error says 'array given').
Check this line:
<input type="text" name="prod_name" id="prod_name" class="form-control" value="<?=((isset($_POST['prod_name']))?sanitize($_POST):' ');?>">
And change it with this:
<input type="text" name="prod_name" id="prod_name" class="form-control" value="<?=((isset($_POST['prod_name']))?sanitize($_POST['prod_name']):' ');?>">
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.
I have these two files and i am updating a table but on the update.php file i get error saying Notice: Undefined index: pname , $pcode...... $pname = $_POST["pname"]; here i am storing pname value in pname variable.but it shows error
<address>
<div class="control-group">
<label class="control-label">Product Name:</label>
<div class="controls">
<input id="pname" name="pname" type="text" value="<?php echo $PName; ?>"
class="input-xlarge">
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<label class="control-label">Product Code:</label>
<div class="controls">
<input id="code" name="pcode" type="text" value="<?php echo $PCode; ?>"
class="input-xlarge">
</div>
</div>
<div class="control-group">
<label class="control-label">Product Price:</label>
<div class="controls">
<input id="price" name="pprice" type="text" value="<?php echo $PPrice; ?>"
class="input-xlarge">
</div>
</div>
<div class="control-group">
<label class="control-label">Availability:</label>
<div class="controls">
<select id="stock" name="stock" class="input-xlarge">
<option value="1" selected="selected">Available</option>
<option value="0">Not Available</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">Product Description:</label>
<div class="controls">
<textarea rows="4" cols="50" name="description" > <?php echo $PDescription; ?> </textarea>
</div>
</div>
<div class="control-group">
Picture 1 :
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="pic1"
class="input-xlarge">
</div>
</div>
<div class="control-group">
Picture 2 :
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="pic2"
class="input-xlarge">
</div>
</div>
<div class="control-group">
Picture 3 :
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="pic3"
class="input-xlarge">
</div>
</div>
<div class="control-group">
<div class="controls">
<input type='hidden' name='id' value="<?php echo $ID; ?>"><br/>
<input type="submit" value="UPDATE" class="btn-large" />
</div>
</div>
</form>
Do you check for form submit?
if (isset($_POST["pname"])) {
// do all your form processing here.
}
$pname= (isset($_POST["pname"]) ? $_POST["pname"] : "");
this will check if pname exists in $_POST and then sets it.
you receive that error because you dont have set $_POST["pname"]