I have a website. With forecasts of sport. When in admin panel want to add new forecasts released the following error:
error!
There was a problem saving the tips: DB Error: Unknown column 'result' in 'field list'
Where is perhaps the error in the system? Can anyone help me with this?
Thank you!
<?php
$tips_open = $this->settings_lib->item('tips.allow_post');
?>
<?php
if (validation_errors()) :
?>
<div class='alert alert-block alert-error animated animated-short zoomIn'>
<a class='close' data-dismiss='alert'>×</a>
<h4 class='alert-heading'>
<?php echo lang('tips_errors_message'); ?>
</h4>
<?php echo validation_errors(); ?>
</div>
<?php
endif;
$id = isset($tips->id) ? $tips->id : '';
?>
<div class="box">
<div class="box-body">
<p class="text-center"><h4><?php if (isset($toolbar_title)) : ?><?php echo $toolbar_title; ?><?php endif; ?>
<span class="pull-right fs12"><span class="hidden-xs"><?php echo lang('tips_action_before_post');?></span>
<button type="button" class="btn btn-blue ml20" data-toggle="modal" data-target="#TipsRules">
<?php echo lang('tips_action_read_rules');?>
</button></span>
</h4></p>
<div class="divider-4"></div>
<?php if ( $tips_open ) { ?>
<?php echo form_open($this->uri->uri_string(), 'id="form" class="form-horizontal"'); ?>
<?php if (isset($current_user->id)) : ?>
<input id="created_by" type="hidden" name="created_by" maxlength="30" value="<?php echo $current_user->id; ?>" />
<?php endif; ?>
<input id="created_on" type="hidden" name="created_on" value="<?php echo date('Y-m-d H:i:s'); ?>" />
<!-- Start Row -->
<div class="row">
<div class="col-sm-4">
<div class="form-group<?php echo form_error('sport_id') ? ' has-error' : ''; ?>">
<?php echo form_label(lang('tips_select_sport') . lang('bf_form_label_required'), 'sport_id', array('class' => 'control-label')); ?>
<select name="sport_id" id="sport_id" class="form-control">
<option value=""><?php echo lang('tips_select_sport');?></option>
<?php foreach ($sports->result() as $row) {
$sel = ($row->id==set_value('sport_id'))?'selected="selected"':'';
?>
<option value="<?php echo $row->id;?>" <?php echo $sel;?>><?php echo $row->name;?></option>
<?php }?>
</select>
<span class='help-block'><?php echo form_error('sport_id'); ?></span>
</div>
</div>
<div class="league">
<div class="col-sm-4">
<div class="form-group<?php echo form_error('league_id') ? ' has-error' : ''; ?>">
<label class="control-label"><?php echo lang('tips_select_league');?></label>
<select name="league_id" id="league_id" class="form-control">
<!-- Auto Populated -->
</select>
<?php echo form_error('league_id');?>
</div>
</div>
</div>
</div>
<!-- End Row -->
<!-- Start Row -->
<div class="row">
<div class="match">
<div class="col-sm-8">
<div class="form-group<?php echo form_error('match_id') ? ' has-error' : ''; ?>">
<?php echo form_label(lang('tips_select_event') . lang('bf_form_label_required'), 'match_id', array('class' => 'control-label')); ?>
<select name="match_id" id="match_id" class="form-control">
<!-- Auto Populated -->
</select>
<?php echo form_error('match_id');?>
</div>
</div>
</div>
</div>
<!-- End Row -->
<!-- Start Row -->
<div class="row">
<div class="bet_id">
<div class="col-sm-4">
<div class="form-group<?php echo form_error('bet_id') ? ' has-error' : ''; ?>">
<?php echo form_label(lang('tips_bet_category') . lang('bf_form_label_required'), 'bet_id', array('class' => 'control-label')); ?>
<select name="bet_id" id="bet_id" class="form-control">
<!-- Auto Populated -->
</select>
<?php echo form_error('bet_id');?>
</div>
</div>
</div>
<div class="choice_id">
<div class="col-sm-5">
<div class="form-group<?php echo form_error('choice_id') ? ' has-error' : ''; ?>">
<?php echo form_label(lang('tips_bet_type') . lang('bf_form_label_required'), 'choice_id', array('class' => 'control-label')); ?>
<select name="choice_id" id="choice_id" class="form-control">
<!-- Auto Populated -->
</select>
<?php echo form_error('choice_id');?>
</div>
</div>
</div>
<div class="stake">
<div class="col-sm-3">
<div class="form-group <?php echo form_error('stake') ? ' has-error' : ''; ?>">
<?php echo form_label(lang('tips_stake') . lang('bf_form_label_required'), 'stake', array('class' => 'control-label')); ?>
<?php $stakes = array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8','9'=>'9','10'=>'10');?>
<select name="stake" id="stake" class="form-control">
<option value=""><?php echo lang('tips_select_stake');?></option>
<?php foreach ($stakes as $stake) {
$sel = ($stake==set_value('stake'))?'selected="selected"':'';
?>
<option value="<?php echo $stake;?>" <?php echo $sel;?>><?php echo $stake;?></option>
<?php }?>
</select>
<span class='help-block'><?php echo form_error('stake'); ?></span>
</div>
</div>
</div>
</div>
<!-- End Row -->
<input type="hidden" name="odds" id="odds" value="" />
<!-- Start Row -->
<div class="row">
<div class="col-sm-12">
<div class="form-group<?php echo form_error('description') ? ' has-error' : ''; ?>">
<?php echo form_label(lang('tips_description') . lang('bf_form_label_required'), 'description', array('class' => 'control-label')); ?>
<textarea class="textarea" name="description" id="description" placeholder="<?php echo lang('tips_min_words');?>" style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
</div>
<span class='help-block'><?php echo form_error('description'); ?></span>
</div>
</div>
<!-- End Row -->
<div class="box-footer">
<input type='submit' name='save' class='btn btn-blue' value="<?php echo lang('tips_action_send'); ?>" />
</div>
<?php echo form_close(); ?>
<?php } else { ?>
<div class="alert alert-info">
<h4> Sorry!</h4>
Cannot bet now.
</div>
<?php } ?>
</div><!-- /.box-body -->
</div><!-- /.box -->
<div id="TipsRules" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content p10">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h1 class="text-center"><?php echo lang('tips_rules'); ?></h1>
</div>
<div class="modal-body" data-ng-controller="rulesCtrl">
<?php $rules = $this->settings_lib->item('tips.rules');
echo $rules
;?>
</div>
<div class="modal-footer bg-default">
</div>
</div>
</div>
</div><!--/modal-->
<script type="text/javascript">
// Define site_url variable for use in the js file
var site_url = "<?php echo site_url(); ?>";
// Define error messages for jquery validation
var description_forgot = '<?php echo lang('tips_desc_forgot');?>'
var description_req = '<?php echo lang('tips_min_words');?>'
</script>
Related
I have created forms to allow me to select member button than retrieve information from the database into the table and update it after made change is working great.
Now I want to move that forms into the BOOTSTRAP MODAL but is not working, when I click the button just slides down bootstrap model AND then DISAPPEAR right away.
What did I miss it…
<form method='post'>
<input type='hidden' name='id' value='" . $row['id_boxe'] . "'/>
<input type='submit' name='update' value='Update' href='#modal-view' role='button' class='btn' data-toggle='modal''/>
</form>
</td>
Retrieve information from database after click button.. (outside modal)
<?php
if (isset($_POST['id'])) {
$id = trim($_POST['id']);
$sql = "SELECT * FROM boxes where id_boxe = " . $id;
$result = $db->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$title = $row['title_boxe'];
$status = $row['status'];
$side = $row['side'];
}
$result->close();
}
?>
Section bootstrap modal: (echo information inside modal)
<div class="modal fade" id="modal-view" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">
Modal title
</h4>
</div>
<div class="modal-body">
<form method="post" class="col-md-6">
<?php if(isset($id)) {?>
<input type="hidden" name="id_boxe" value="<?=$id?>"/>
<?php } ?>
<div class="form-group">
<label for="boxe_title">Boxe Title</label>
<input type="text" class="form-control" name="boxe_title" value="<?php if(isset($title)) echo $title; ?>">
</div>
<div class="checkbox">
<select name="side">
<?php if(isset($side) && $side == 1) { ?>
<option value="1" selected>right</option>
<?php } else {?>
<option value="1">right</option>
<?php } ?>
<?php if(isset($side) && $side == 2) { ?>
<option value="2" selected>left</op)tion>
<?php } else {?>
<option value="2">left</option>
<?php } ?>
</select>
</div>
<div class="select">
<?php if(isset($status) && $status == 1) { ?>
<label><input type="checkbox" name="visibility" checked> Visible in the Menu</label>
<?php } else {?>
<label><input type="checkbox" name="visibility" > Visible in the Menu</label>
<?php } ?>
</div>
<?php if (isset($_POST['id'])) { ?>
<button type="submit" name="updatedata" class="btn btn-default">Update</button>
<?php } else { ?>
<button type="submit" name="add" class="btn btn-default">Add</button>
<?php } ?>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
<button type="button" class="btn btn-primary">
Save changes
</button>
</div>
</div>
</div>
</div>
My question is that what did I missed to show bootstrap modal with profile information instead of disappear bootstrap modal!
Is works fine before bootstrap modal but after moved that forms to bootstrap modal is not working..
What I missed!
Thank you for your help…
AM
My guess is that the form with the submit button is causing the problem, perhaps it is showing the modal quickly because of the data-toggle on the submit button but then since you are triggering a form submit it reloads the page causing the modal to disappear.
Try changing your button to:
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#modal-view">Launch demo modal</button>
Like it shows in the demo on bootstrap's site.
Also you might want to read up on SQL Injection because your code looks vulnerable.
It is hard to tell what the problem is with the modal without seeing a full HTML output, can you provide that in jsfiddle?
I have 2 input arrays one is checkbox and and another one is textbox
which is my view file
<div class="form-group">
<label class="col-lg-2 control-label">Fee Types</label>
<div class="col-lg-8">
<div class="checkbox">
<?php foreach($types as $key=>$value){?>
<label>
<input type="checkbox" value="<?php echo $value['id'] ?>" name="type_id[]" />
<span class="text"><?php echo $value['name'] ?></span>
</label>
<input type="text" class="form-control" name="amount[]" />
<?php } ?>
</div>
</div>
</div>
which is my controller
$data=array(
'id'=>$this->input->post('id'),
'amount'=>$this->input->post('amount'),
'type_id'=>$this->input->post('type_id'),
'created_date'=>date('Y-m-d'),
);
$this->user->details($data);
could anyone tell me how to insert those two arrays as multiple records
$checkboxes = $this->input->post('type_id[]');
$amounts= $this->input->post('amount[]');
for ($i = 0; $i < count($amounts); $i++) {
$data = array(
'id'=> $yourIdPostField,
'amount'=>$amounts[$i],
'type_id'=> $checkboxes[$i],
'created_date'=>date('Y-m-d'),
);
$this->user->details($data);
}
This is simple way... but maybe your problem is no checkbox post data becouse not checked, if you want that problem then add increment number to your form ...
<div class="form-group">
<label class="col-lg-2 control-label">Fee Types</label>
<div class="col-lg-8">
<div class="checkbox">
<?php foreach($types as $key=>$value){?>
<label>
<input type="checkbox" value="<?php echo $value['id'] ?>" name="type_id[$key]" />
<span class="text"><?php echo $value['name'] ?></span>
</label>
<input type="text" class="form-control" name="amount[<?php echo $key ?>]" />
<?php } ?>
</div>
</div>
</div>
$checkboxes = $this->input->post('type_id[]');
$amounts= $this->input->post('amount[]');
$example1 = implode(" ",$checkboxes);
$example2 = implode(" ",$amounts);
Please try this. I hope your problem will be solve.
$checkboxes, $amounts this variables is array so these variable value could not store in your database. So please convert array to string.
Thanks
I am currently making a registration form what I want is to have a modal what will appear whenever a user has successfully registered into the database how I am able to do this ?
this is my view
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Register</title>
<?php echo link_tag('css/bootstrap.min.css'); ?>
<?php echo link_tag('jumbotron-narrow.css'); ?>
<?php echo link_tag('styles/menu.css'); ?>
<?php echo link_tag('styles/form.css'); ?>
</head>
<body class='bg'>
<div class='header'>
<img src = "<?php echo base_url() . '/images/tf_header.png' ?>"/>
</div>
<?php if (validation_errors()): ?>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<?php echo validation_errors(); ?>
</div>
<?php endif; ?>
<div class ="container center-block">
<br>
<div class ="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Registration</h3>
</div>
<div class="panel-body">
<form class="form" action="<?php echo base_url() . 'user/addDelegate'; ?>" method="post" class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">Surname:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter Surname" name="surname" value="<?php echo set_value('surname'); ?>">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">First Name:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter First Name" name="firstname"value="<?php echo set_value('firstname'); ?>" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">Course:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter your Course" name="course" value="<?php echo set_value('course'); ?>">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">Email:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter email address" name="email" value="<?php echo set_value('email'); ?>">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success">Register</button>
Back
</div>
</div>
</form>
</div>
</div>
</div>
<div class="footer">
<img src = "<?php echo base_url() . '/images/tf_footer.png' ?>"/>
</div>
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
the controller:
public function addDelegate(){
$this->form_validation->set_rules('surname', 'surname', 'required');
$this->form_validation->set_rules('firstname', 'firstname', 'required');
$this->form_validation->set_rules('age', 'Age', 'required|is_numeric');
$this->form_validation->set_rules('course', 'Course', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
if ($this->form_validation->run() == TRUE) {
$reg_dat = array(
'surname' => $this->input->post('surname'),
'name' => $this->input->post('firstname'),
'age' => $this->input->post('age'),
'course' => ($this->input->post('course')),
'email' => ($this->input->post('email')),
);
$this->load->view('user/home_view');
$this->user_model->add_user($reg_dat);
$this->load->view('user/individual_register');
} else {
$this->load->view('user/individual_register');
}
}
Try this code
model
class User_Model extends CI_Model
{
public function __construct()
{
$this->load->database();
}
public function add_user($data)
{
if($this->db->insert('tablename', $data))
{
return TRUE;
}else
{
return FALSE;
}
}
}
controller
public function addDelegate(){
$this->form_validation->set_rules('surname', 'surname', 'required');
$this->form_validation->set_rules('firstname', 'firstname', 'required');
$this->form_validation->set_rules('age', 'Age', 'required|is_numeric');
$this->form_validation->set_rules('course', 'Course', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
if ($this->form_validation->run() === FALSE) {
$this->load->view('');
}else
{
$reg_dat = array(
'surname' => $this->input->post('surname'),
'name' => $this->input->post('firstname'),
'age' => $this->input->post('age'),
'course' => ($this->input->post('course')),
'email' => ($this->input->post('email')),
);
//call method from model
if($this->user_model->add_user($reg_dat) === TRUE)
{
$data['message'] = 'Insert success';
//load your view page
$this->load->view('user/home_view',$data);
}else
{
$data['message'] = 'insert failled';
// load your view page
$this->load->view('user/home_view',$data);
}
} else {
// load your register page
$this->load->view('user/individual_register');
}
}
view
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Register</title>
<?php echo link_tag('css/bootstrap.min.css'); ?>
<?php echo link_tag('jumbotron-narrow.css'); ?>
<?php echo link_tag('styles/menu.css'); ?>
<?php echo link_tag('styles/form.css'); ?>
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</head>
<body class='bg'>
<div class='header'>
<img src = "<?php echo base_url() . '/images/tf_header.png' ?>"/>
</div>
<?php if (validation_errors()): ?>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<?php echo validation_errors(); ?>
</div>
<?php endif; ?>
<div class ="container center-block">
<br>
<div class ="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Registration</h3>
</div>
<div class="panel-body">
<?php echo form_open(base_url('user/addDelegate'),['name' => 'addform', 'id' => 'addform', 'class' => 'form-horizontal', 'role' => 'form']) ?>
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">Surname:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter Surname" name="surname" value="<?php echo set_value('surname'); ?>">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">First Name:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter First Name" name="firstname"value="<?php echo set_value('firstname'); ?>" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">Course:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter your Course" name="course" value="<?php echo set_value('course'); ?>">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">Email:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter email address" name="email" value="<?php echo set_value('email'); ?>">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success">Register</button>
Back
</div>
</div>
</form>
</div>
</div>
</div>
<div class="footer">
<img src = "<?php echo base_url('images/tf_footer.png')?>"/>
</div>
</body>
</html>
I am currently making a module where a user would upload an image with some details to the database but its not working not even the validations are showing up i already created the uploads directory for the images
controller:
public function do_upload() {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1024';
$config['max_width'] = '1024';
$config['max_height'] = '1024';
$config['new_image'] = './uploads/';
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
$this->form_validation->set_rules('type', 'Type', 'required');
$this->form_validation->set_rules('school', 'School', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
if (!$this->upload->do_upload() || !$this->form_validation->run()) {
$error = array('error' => $this->upload->display_errors());
redirect('user/payment');
} else {
$data = $this->upload->data();
$this->thumb($data);
$file = array(
'img_name' => $data['raw_name'],
'thumb_name' => $data['raw_name'] . '_thumb',
'ext' => $data['file_ext'],
'type' => $this->input->post('type'),
'school' => $this->input->post('school'),
'email' => $this->input->post('email'),
);
$data = array('upload_data' => $this->upload->data());
$this->user_model->add_image($file);
// redirect('user/home_register');
$this->load->view('user/upload_success');
}
}
public function thumb($data) {
$config['image_library'] = 'gd2';
$config['source_image'] = $data['full_path'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 275;
$config['height'] = 250;
$config['new_image'] = './thumbs/';
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
View:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Technofest - user</title>
<?php echo link_tag('css/bootstrap.min.css'); ?>
<?php echo link_tag('jumbotron-narrow.css'); ?>
</head>
<body>
<br>
<div align="center">
</div>
<br>
<div class ="container">
<ul class="nav nav-pills nav-justified">
<li role="presentation">Home</li>
<li role="presentation" >About</li>
<li role="presentation">Contact</li>
<li role="presentation" class="active" >Register</li>
</ul>
</div>
<br>
<br>
<div>
<?php echo form_open_multipart('user/do_upload'); ?>
<?php if (validation_errors()): ?>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<?php echo validation_errors(); ?>
</div>
<?php endif ?>
<div class ="container center-block">
<div class="jumbotron">
<div class ="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Payment</h3>
</div>
<div class="panel-body">
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">Type:</label>
<input type="radio" id="indiv" name="regtype" value="<?php echo set_value('type'); ?>" id='1'<?php echo set_radio('type','Individual', TRUE)?>/> Invidivual
<input id="bat" type="radio" name="regtype" value="<?php echo set_value('type'); ?>" id='2' <?php echo set_radio('type','Batch')?>/> Batch
<?php echo form_error('type'); ?>
<br><br>
<label class="col-sm-2 control-label">Payment for:</label>
</div>
</div>
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">School:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter School Name" name="school" value="<?php echo set_value('school'); ?>">
</div>
</div>
</div>
<?php echo form_error('school'); ?>
<div class="form-group">
<div class="row">
<label class="col-sm-2 control-label">Email:</label>
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="Enter Email" name="Email" value="<?php echo set_value('email'); ?>">
</div>
</div>
</div>
<?php echo form_error('email'); ?>
<input type="file" id="imgInp" name = "pic" required width = "10px">
<div class="col-sm-offset-2 col-sm-10">
<button type="button, submit" class="btn btn-primary " style="border-radius: 0;">
Upload
</button>
Back
</div>
<?php echo form_close() ?>
</div>
</div>
</div>
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
model
function add_image($data) {
$this->db->set('payment_date', 'NOW()', FALSE);
$this->db->insert('payment', $data);
}
I have 8 fields in db
id(auto increment),payment_data,type,school,email,img_name,thumb_name and ext
Try adding pic field name to
$this->upload->do_upload('pic')
And Change Raw Name to file_name
Try giving the name = "userfile"
just replace your
<input type="file" id="imgInp" name = "pic" required width = "10px">
with
<input type="file" id="imgInp" name = "userfile" required width = "10px">
I've 2 ajax form in my ctp,
One is working and other is not,instead it gets redirected.
This is my .ctp file
<div>
<?php echo $ajax->form('deletecreativeschedule','post',array('id'=>'delete','model'=>'admin','update'=>'myTable')); ?>
<input type="hidden" id="deviceid" name="deviceid" value="<?php echo $device['Device']['id'] ?>" />
<input type="hidden" name="scheduleid" id="scheduleid"/>
<input name="btnDelete" type="image" src="/<?php echo $site_root ?>/img/btnDelete.gif" height="16" class="sbtnDelete" id="sbtnDelete" onclick="return deleteSchedule();" title="Delete creative" >
<?php echo $form->end(); ?>
<br>
<?php echo $ajax->form('swapcreativeschedule','post',array('id'=>'swap','controller'=>'admin','update'=>'myTable')); ?>
<input type="hidden" id="deviceid" name="deviceid" value="<?php echo $device['Device']['id'] ?>" />
<input type="hidden" name="aIdAjax" id="aIdAjax"/>
<input type="hidden" name="aSeqAjax" id="aSeqAjax"/>
<input name="btnUP" type="image" src="/<?php echo $site_root ?>/img/up.png" class="sbtnup" id="sbtnup" onclick="return SwapRow('0');" title="Delete creative" >
<input name="btnDown" type="image" src="/<?php echo $site_root ?>/img/down.png" class="sbtndown" id="sbtnup" onclick="return SwapRow('1');" title="Delete creative" >
<?php echo $form->end(); ?>
and in controller:
function deletecreativeschedule()
{
$this->autorender = false;
$this->layout = 'ajax';
}
function swapcreativeschedule()
{
$this->autorender = false;
$this->layout = 'ajax';
}
and in views/admin folder i've created files deletecreativeschedule.ctp and swapcreativeschedule.ctp
ajax is working fine for deleteschedule
but for swapcreativeschedule it is redirecting to /admin/swapcreativeschedule
what is wrong here?
I hope it'll work,
<?php echo $form->create('deletecreativeschedule'); ?>
<input type="hidden" id="deviceid" name="deviceid" value="<?php echo $device['Device']['id'] ?>" />
<input type="hidden" name="scheduleid" id="scheduleid"/>
<input name="btnDelete" type="image" src="/<?php echo $site_root ?>/img/btnDelete.gif" height="16" class="sbtnDelete" id="sbtnDelete" onclick="return deleteSchedule();" title="Delete creative" >
<? echo $ajax->submit('btnDelete.gif',array("url"=>array('controller'=>'your controller','action'=>'ur action',$device['Device']['id']),'class'=>'sbtnDelete','update'=>'ur updateDiv') ?>
<?php echo $form->end(); ?>
<br>
<?php echo $form->create('swapcreativeschedule'); ?>
<input type="hidden" id="deviceid" name="deviceid" value="<?php echo $device['Device']['id'] ?>" />
<input type="hidden" name="aIdAjax" id="aIdAjax"/>
<input type="hidden" name="aSeqAjax" id="aSeqAjax"/>
<? echo $ajax->submit('up.png',array("url"=>array('controller'=>'your controller','action'=>'ur action',$device['Device']['id']),'class'=>'sbtnup','update'=>'ur updateDiv') ?>
<? echo $ajax->submit('down.png',array("url"=>array('controller'=>'your controller','action'=>'ur action',$device['Device']['id']),'class'=>'sbtndown','update'=>'ur updateDiv') ?>
<?php echo $form->end(); ?>