I have a view page.i have to edit a list of values.bt after submit i have an error disallowed character key.I cant find it how this error occur.
view
foreach($track_details->result() as $name) { ?>
<form class="form-horizontal" method="post" id="income_edit" action="<?php echo base_url();?>income_list_cntrl/update_income" enctype="multipart/form-data">
<input type="text" name="track_id" value="<?php echo $track_id; ?>" >
<div class="control-group">
<label class="control-label">Income Name</label>
<div class="controls">
<input type="text" class="span6 m-wrap" value="<?echo $name->income_name?>" name="income_name" id="income_name" readonly>
<?php echo form_error('income_name'); ?>
</div>
</div>
<div class="control-group">
<label class="control-label">Income Amount</label>
<div class="controls">
<input type="text" class="span6 m-wrap" value="<?echo $name->income_amount?>" name="income_amount" id="income_amount" >
<?php echo form_error('income_amount'); ?>
</div>
</div>
<div class="control-group">
<label class="control-label">Crop Quantity</label>
<div class="controls">
<input type="text" class="span6 m-wrap" value="<?echo $name->crop_quantity?>" name=crop_quantity" id="crop_quantity" >
<?php echo form_error('crop_quantity'); ?>
</div>
</div>
<div class="control-group">
<label class="control-label">Per Rate</label>
<div class="controls">
<input type="text" class="span6 m-wrap" value="<?echo $name->per_rate?>" name=per_rate" id="per_rate" >
<?php echo form_error('per_rate'); ?>
</div>
</div>
<div class="control-group">
<label class="control-label">Choose a client</label>
<div class="controls">
<select class="span6 m-wrap" name="select_client" >
<? foreach ($client_details->result() as $var) { ?>
<option <?php if($name->client_id == $var->client_id) { ?> selected="selected" <? } ?> value="<?echo $var->client_id;?>"><?echo $var->client_name;?></option>
<?}?>
</select>
<?php echo form_error('select_client'); ?>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn green" id="Submit">Submit</button>
</form>
<?}?>
controller
After removing the crop quantity and per rate no error but dont edit it.
public function update_income(){
$this->form_validation->set_error_delimiters('<div style="color:#B94A48">', '</div>');
//$this->form_validation->set_rules('income_name', 'Income name', 'required');
$this->form_validation->set_rules('income_amount', 'Income Amount', 'required');
$this->form_validation->set_rules('crop_quantity', 'Crop Quantity', 'required');
$this->form_validation->set_rules('per_rate', 'Per Rate', 'required');
$this->form_validation->set_rules('select_client', 'Client Name', 'required');
if ( $this -> form_validation -> run() === FALSE ){
$this->index();
} else {
$track_id=$this->input->post('track_id');
$income_name=$this->input->post('income_name');
$income_amount=$this->input->post('income_amount');
$crop_quantity=$this->input->post('crop_quantity');
$per_rate=$this->input->post('per_rate');
$client_name=$this->input->post('select_client');
$this->load->model('income_edit_model');
$data = array(
'income_name'=>$income_name,
'income_amount'=>$income_amount,
'crop_quantity'=>$crop_quantity,
'per_rate'=>$per_rate,
'client_name'=>$client_name,
);
$result=$this->income_edit_model->update_track_income($data,$track_id);
// redirect(base_url().'income', 'refresh');
}
}
Two problems:
First: Missing <?php open tags. Look through this and change <? to <?php
<select class="span6 m-wrap" name="select_client" >
<? foreach ($client_details->result() as $var) { ?>
<option <?php if($name->client_id == $var->client_id) { ?> selected="selected" <? } ?> value="<?echo $var->client_id;?>"><?echo $var->client_name;?></option>
<? } ?>
</select>
Second: Missing closing </div
<div class="form-actions">
<button type="submit" class="btn green" id="Submit">Submit</button>
<!-- MISSING </div> HERE -->
</form>
Related
i display with a foreach the content of a user_meta in wordpress. It displays input taht fills with the values (so they can be changed). I want to be able to store each content in a new array (so i can update the user_meta next.
So here is the main code :
<?php
function edit_profile_form() {
$current_user_id = get_current_user_id();
$data = get_user_meta ($current_user_id);
if (isset($_POST['button2'])) {
delete_user_meta($current_user_id, 'experiences');
}
if(isset($_POST['button1'])) {
save_extra_profile_fields($current_user_id);
};
$experiences = get_user_meta($current_user_id, 'experiences', true);
?>
<div class="container_form">
<form method="POST">
<h3>Vos expériences</h3>
<div class="experiences_container">
<?php
if (!empty($experiences)) {
$index=0;
foreach ($experiences as $key) {
$index++;
echo($index);
echo($key);
?>
<div class="past_experience">
<div class="experience_header">
<div>
<label for="team">Nom de l'équipe</label>
<input class="team" name="team" value="<?= $key['new_experience_team'];?>"/>
</div>
<div>
<label for="role">Rôle dans l'équipe</label>
<input class="role" name="role" value="<?= $key['new_experience_role'];?>"/>
</div>
</div>
<div class="experience_textarea">
<label for="description">Description du rôle</label>
<textarea class="description" name="description"><?= $key['new_experience_description']; ?></textarea>
<label for="palmares">Palmarés avec l'équipe</label>
<textarea class="palmares" name="palmares"><?= $key['new_experience_palmares']; ?></textarea>
</div>
</div>
<?php
}
} else {
?>
<div><p>Vous n'avez encore rentré aucune expérience</p></div>
<?php
}?>
</div>
<div class="add_container">
<div id="dropdown">
<i class="fas fa-plus-square" style="margin-right: 5px;"></i>
<p id="show" onClick="dropdown()" >Ajouter une expérience</p>
</div>
<div id="experience" style="display:none;">
<label for="new_experience_team">Nom de l'équipe</label>
<input type="text" name="experiences[new_experience_team]" id="experience_team">
<label for="new_experience_role">Rôle dans l'équipe</label>
<input type="text" name="experiences[new_experience_role]" id="experience_role">
<label for="new_experience_description">Description du poste</label>
<textarea type="text" name="experiences[new_experience_description]" id="experience_description"></textarea>
<label for="new_experience_palmares">Palmarés</label>
<textarea type="text" name="experiences[new_experience_palmares]" id="experience_palmares"></textarea>
</div>
</div>
<div id="button_container">
<input type="submit" name="button1" value="Sauvegarder" id='save'/>
<input type="submit" name="button2" value="Annuler"/>
</div>
</form>
</div>
The function's one :
<?php
function save_extra_profile_fields( $user_id ) {
if (!empty($_POST['experiences'])) {
$savedexperience = get_user_meta($user_id, 'experiences', true);
if (!empty($savedexperience) && is_array($savedexperience )) {
$experiences = $savedexperience;
}
$experiences[] = $_POST['experiences'];
update_usermeta($user_id, 'experiences', $experiences);
}
}
So i want to be able to stock in a array each group of team, role, description and palmares.
I don't know if it's clear at all :/
Thanks all
I am trying to make a radio button with 2 options i.e. option A and Option B.
I have 2 text input ( A and B ) and some other text input that always has to be there.
Option A of the radio button has to make disappear text input (A) and show another text input (B). Option B should make this the opposite. ( disappear text input (B) and show another text input (A) )
I don't know how to make that 2 text inputs.
will appreciate some help.
<form class="user" id="RegisterForm" action="" method="post">
<? print("USER ROLE : ") ?>
<input type="radio" name="user_role" <?php if (isset($user_role) && $user_role=="A") echo "checked";?> value="A">A
<input type="radio" name="user_role" <?php if (isset($user_role) && $user_role=="B") echo "checked";?> value="B">B
//REST OF the code defines some text inputs that are always should show.
<?php if ($fullname_req != "-1") { ?>
<div class="form-group">
<input type="text" class="form-control form-control-user" id="displayname" name="fullname" placeholder="<?php _e('Display name', 'user-panel-pro') ?>">
</div>
<?php } ?>
<?php if ($firstname_req != "-1") { ?>
<div class="form-group row">
<?php if ($firstname_req != "-1" or $lastname_req != "-1") { ?>
<div class="col-sm-6 mb-3 mb-sm-0">
<input type="text" class="form-control form-control-user" id="First-Name" name="firstname" placeholder="<?php _e('first name', 'user-panel-pro') ?>">
</div>
<?php } ?>
<?php if ($lastname_req != "-1") { ?>
<div class="col-sm-6">
<input type="text" class="form-control form-control-user" id="Last-Name" name="lastname" placeholder="<?php _e('last name', 'user-panel-pro') ?>">
</div>
<?php } ?>
</div>
<?php } ?>
<?php if ($username_req != "-1") { ?>
<div class="form-group">
<input type="text" class="form-control form-control-user" id="User-Name" name="username" placeholder="<?php _e('Username', 'user-panel-pro') ?>">
</div>
<?php } ?>
<?php if ($email_req != "-1") { ?>
<div class="form-group">
<input type="email" class="form-control form-control-user" id="Email" name="email" placeholder="<?php _e('Email', 'user-panel-pro') ?>">
</div>
<?php } ?>
I am not able to understand your code, so I am just giving a small demo
<div class="radioBtns">
<label for='rbtnLoginTypeMobile'><input checked type="radio" id="rbtnLoginTypeMobile" name="rbtnLoginType" value='1' onclick="showLogin(1)"/><span>Mobile</span></label>
<label for='rbtnLoginTypeEmail'><input type="radio" id="rbtnLoginTypeEmail" name="rbtnLoginType" value='0' onclick="showLogin(0)" /><span>Email</span></label>
</div>
<div class="mobilelogin">Your Mobile Div</div>
<div class="emaillogin">Your Email Div</div>
<script type="text/javascript">
function showLogin(val)
{
if(val==1)
{
$('.emaillogin').css('display','none');
$('.mobilelogin').css('display','');
}
else
{
$('.mobilelogin').css('display','none');
$('.emaillogin').css('display','');
}
}
</script>
In codeigniter I want to add the product on admin Id which is required in DB Table. when Admin log in his ID must be catch. whenever and where Id is needed it must be available.
here is my VIEW in which
<?php echo form_open_multipart('admin/add_product');?>
<!------------------Product Name------------------------>
<div class="row form-group">
<div class="col-sm-10">
<label>Product Name: *</label>
<?php echo form_input(['name'=>'name','class'=>'form-
control','placeholder'=>'Product name..','value'=>
set_value('name')])?>
<div>
<?php echo form_error('name');?>
</div>
</div></div>
<!------------------Product Cat---------------------------->
<div class="row form-group">
<div class="col-sm-12">
<label>Category: *</label> <br>
<select class="selectpicker" name="pro_cat_id">
<option label="Select Category">Category</option>
<?php
foreach($product_cat as $cat)
{?>
<option value="<?= $cat['pro_cat_id'] ?>"><?= $cat['category'] ?>
</option>
<?php }?>
</select>
<div>
<!------------------Product Price---------------------------->
<div class="row form-group">
<div class="col-md-10">
<label>Product Price: *</label>
<?php echo form_input(['name'=>'price','class'=>'form-
control','placeholder'=>'Product Price..','value'=>
set_value('price')])?>
<div>
<?php echo form_error('price');?>
</div>
</div></div>
<!------------------Product Location---------------------------->
<div class="row form-group">
<div class="col-md-10">
<label>Product Location: *</label>
<?php //echo form_input(['name'=>'location','class'=>'form-
control','placeholder'=>'Product Location'])?>
</div></div>
</div></div>
<!-----------End of body---------------->
</div>
<div class="modal-footer">
<input name="" type="submit" value="ADD" class="btn btn-success">
</div>
<?php echo form_close();?>
</div>
</div>
</div>
Here is my Controller
function add_product(){
$data['product_size'] = $this->show->show_product_size();
$data['product_cat']= $this->show->show_product_category();
$data['product_color'] = $this->show->show_product_color();
$data['pr']= $this->show->show_provider();
$post= $this->input->post();
$ =this->form_validation->set_error_delimiters("<p class='text-danger'>","
</p>");
if($this->form_validation->run('add_product')){
if($this->add->add_product($post)==TRUE){
$this->db->close();
$this->session->set_flashdata('success','Product has been added
successfully');
return redirect('admins/pages/add_product_page');
//$this->load->admin_template('admin/add_product',$data);
}
}
else
{
$this->session->set_flashdata('failled','Sorry, fail to add product');
//return redirect('admins/pages/add_product_page');
$upload_error= $this->upload->display_errors();
$this->load->admin_template('admin/add_product',$data);
}
}
Use this query, preferably in your controller:
$this->session->userdata('id');
Outputted a row from a table ,am now trying to add some of the contents to another table using a form which is inside the outputted row but its not inserted to the database. am not getting an error.
Here is my view
<?php
foreach ($h->result() as $row)
{?>
<div class="row invoice-info">
<div class="col-sm-1 invoice-col">
</div>
<div class="col-sm-3 invoice-col">
<img src="<?php echo base_url()?>/res/images/goods/1.png">
</div>
<div class="col-sm-4 invoice-col">
<address>
Description: <?php echo $row->description;?><br>
Location Address: <?php echo $row->l_area;?><br>
Destination Address: <?php echo $row->d_area;?><br>
Date: <?php echo $row->dom;?><br>
Time: <?php echo $row->tom;?>
</address>
</div>
<div class="col-sm-2 invoice-col">
<address>
</address>
</div><!-- /.col -->
<div class="col-sm-2 invoice-col">
<form action="<?php echo site_url('truckeraccount_ctrl/bid'); ?>" method="post">
<input type="hidden" class="form-control" name="truckerid" value="<?php
$truckerid = $this->session->userdata('truckerid');
echo $truckerid; ?>" required>
<input type="hidden" class="form-control" name="luggage_id" value="<?php echo $row->luggage_id;?>" placeholder="Bid">
<input type="text" class="form-control" name="bid_amount" placeholder="Bid">
<button type="submit" class="btn bg-orange btn-flat margin">Place Bid</button>
</div>
</div>
My model
function bid($data){
$query=$this->db->update('bids',$data);
return $query;
}
My controller
public function bid(){
$this->load->database();
$this->load->model('Truckeraccount_model');
$data['a']=$this->Truckeraccount_model->accepted_bid();
$data['b']=$this->Truckeraccount_model->picked_loads();
$data['h']=$this->Truckeraccount_model->loads();
$data['g']=$this->Truckeraccount_model->notification();
$data['i']=$this->Truckeraccount_model->return_loads();
$data['accepted_return_loads']=$this->Truckeraccount_model->accepted_return_loads();
$data['bid_amount']=$this->Truckeraccount_model->bid_amount(); $this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
$this->form_validation->set_rules('bid_amount', 'bid_amount', 'required|min_length[1]|max_length[50]');
if ($this->form_validation->run() == FALSE) {
$this->load->view('header');
$this->load->view('truckeraccount_view',$data);
$this->load->view('footer');
} else {
$data = array(
'truckerid' => $this->input->post('truckerid'),
'luggage_id' => $this->input->post('luggage_id'),
'bid_amount' => $this->input->post('bid_amount'),
);
$this->Truckeraccount_model->bid($data);
$data['message'] = '';
redirect('truckeraccount_ctrl/');
}
}
<form action="<?php echo site_url('truckeraccount_ctrl/bid'); ?>" method="post">
<input type="hidden" class="form-control" name="truckerid" value="<?php
$truckerid = $this->session->userdata('truckerid');
echo $truckerid; ?>" required>
<input type="hidden" class="form-control" name="luggage_id" value="<?php echo $row->luggage_id;?>" placeholder="Bid">
<input type="text" class="form-control" name="bid_amount" placeholder="Bid">
<button type="submit" class="btn bg-orange btn-flat margin">Place Bid</button>
</form>
I want to update data with different tables . but it redirect to "The URI you submitted have disallowed characters"I have tables like this. please help me :(((
recipe
category
category_ingredient
ingredient
menu
time
Here's my code:
VIEW:edit_product.php
<?php echo form_open('dashboard/save_edit_recipe/$product_id', 'class="form-horizontal" enctype="multipart/form-data"'); ?>
<?php foreach($recipe_info as $row): ?>
<input type="hidden" id="hide" name="recipe_id" value="<?php echo $row->recipe_id; ?>" class="form-control"><br/>
<div class="form-group">
<div class="col-sm-10">
<input class="form-control" type="text" name="r_name" placeholder="Recipe name" required value="<?php echo $row->r_name; ?>">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<select required class="form-control" name="recipe_category">
<?php $recipe_category = $this->products_model->getRecipeCategory($row->recipe_id); ?>
<option value="" selected disabled>Select Recipe Category</option>
<option value="All">All</option>
<?php foreach($this->products_model->getCategory() as $cat): ?>
<?php if($cat->category_id == $recipe_category): ?>
<option selected value="<?php echo $cat->category_id ?>"><?php echo $cat->name ?></option>
<?php else: ?>
<option value="<?php echo $cat->category_id ?>"><?php echo $cat->name ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label>Pick Ingredients:</label>
<div class="row" id="categoryIngredients" >
<?php $ingredients = $this->products_model->getRecipeIngridients($row->recipe_id); ?>
<?php foreach($this->products_model->geIngredientsInCategory($recipe_category) as $ing): ?>
<div class="col-sm-3"><div class="checkbox"><label><input type="checkbox" name="ingredients[]" value="<?php echo $ing->ingredient_id ?>" <?php echo (in_array($ing->ingredient_id, $ingredients) >= -1 ? 'checked' : '') ?>><?php echo $ing->name ?></label></div></div>
<?php endforeach; ?>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label>Type your Procedure</label><br/>
<textarea id="recipeProcedure" name="recipe_procedure" rows="10" class="form-control" placeholder="Procedure"><?php echo $row->r_procedure ?></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<select required class="form-control" name="cooking_time">
<option value=""selected disabled>Select Cooking time</option>
<?php foreach($this->products_model->getRecipeCookingTime() as $time): ?>
<?php if($row->time_id == $time->time_id): ?>
<option selected value="<?php echo $time->time_id ?>"><?php echo $time->name ?></option>
<?php else: ?>
<option value="<?php echo $time->time_id ?>"><?php echo $time->name ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<textarea class="form-control" rows="5" placeholder="Description" name="r_description" required><?php echo $row->r_description; ?></textarea>
</div>
</div>
<div class="form-group">
<div class='col-sm-10'>
<input class='form-control' type="text" placeholder="Calories" name="calories" required value="<?php echo $row->r_cal ?>">
</div>
</div>
<div class="form-group">
<div class='col-sm-10'>
<input class='form-control' type="text" placeholder="Serving Size" name="serving_size" required value="<?php echo $row->r_serve ?>">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<label>Upload Thumbnail</label>
<input type="file" name="r_image" required>
<div>
<img style="width:50%;height:50%;"<?php echo img(base_url().$row->r_image); ?>
</div>
</div>
</div>
<div class='form-group'>
<div class="col-sm-10">
<button class="btn btn-lg btn-positive" type="submit"><i class="glyphicon glyphicon-ok"></i> Save Recipe</button>
</div>
</div>
<?php endforeach; ?>
<?php echo form_close(); ?>
CONTROLLER:
function edit_product($product_id)
{
$data = array('recipe_info' => $this->products_model->getRcipe($this->uri->segment(3)),
'product_id' => $this->uri->segment(3)
);
/*var_dump($data); die();*/
$this->load->view('edit_product', $data);
}
public function save_edit_recipe()
{
$this->load->model('products_model');
$product_id= $this->input->post('recipe_id');
$data = array(
'r_name' => $this->input->post('r_name'),
'r_image' => '',
'r_description' => $this->input->post('r_description'),
'time_id' => $this->input->post('cooking_time'),
'r_cal' => $this->input->post('calories'),
'r_serve' => $this->input->post('serving_size'),
);
$this->products_model->update_product($product_id,$data);
$this->getRcipe();
}
MODEL:products_model.php
function getRcipe($recipe_id)
{
$this->db->where('recipe_id', $recipe_id);
$query = $this->db->get('recipe');
return $query->result();
}
Find what your disallowed characters are which will be in your url it could be ?&=
Then go to your config.php and you can add them here.
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
Restart or Refresh Server afterwords.
Also in your form_open
<?php echo form_open('dashboard/save_edit_recipe/$product_id', 'class="form-horizontal" enctype="multipart/form-data"'); ?>
To $product_id product id was not correct
<?php echo form_open('dashboard/save_edit_recipe/' . $product_id, 'class="form-horizontal" enctype="multipart/form-data"'); ?>
If you need to use mulitpart / form helper codeigniter one
<?php echo form_open_multipart('dashboard/save_edit_recipe' .'/'. $product_id, array('class' => 'form-horizontal'));?>
Update:
$this->products_model->update_product($this->uri->segment(3), $data);