【发布时间】:2018-12-03 12:50:42
【问题描述】:
当我更改此 $this->load->view('profile',['getPlacetype'=>$getPlacetype],$custom_errors );对此 $this->load->view('profile',['getPlacetype'=>$getPlacetype],$custom_errors ); 将没有未定义的索引,但选择数据将是无
profilecon
public function index(){
$this->load->model('Placetype');
$getPlacetype = $this->Placetype->getPlacetype();
if (!isset($_SESSION['username']) || empty($_SESSION['username'])) {
header("Location: ".base_url()."index.php/login_con/login");
die();
}
$custom_errors["nadate"] = false;
if (isset($_POST['profile'])) {
$this->form_validation->set_rules('mobilenum', 'Mobile Number',
'required');
$this->form_validation->set_rules('homeadd', 'Home Address',
'required');
$this->form_validation->set_rules('startdate', 'Start Date',
'required');
$this->form_validation->set_rules('enddate', 'End Date',
'required');
$custom_errors["nadate"] = ($this->verifydate($_POST["startdate"],
$_POST["enddate"]) < 3 ? false : true);
//if form validation true
if($this->form_validation->run() == TRUE && $this-
>verifydate($_POST["startdate"], $_POST["enddate"]) < 3) {
$data = array(
'username' => $this->session->userdata("username"),
'mobilenum' => $_POST['mobilenum'],
'homeadd' => $_POST['homeadd'],
'startdate' => $_POST['startdate'],
'enddate' => $_POST['enddate'],
);
$_SESSION["profile_data"] = $data;
redirect("shopping_cart","refresh");
}
}
$this->load->view('profile',
['getPlacetype'=>$getPlacetype],$custom_errors );
}
placetype_model
<?php
class Placetype extends CI_MODEL{
public function getPlacetype(){
$query = $this->db->get('placetype');
if($query->num_rows() > 0){
return $query->result();
}
}
}
profile_view
<div class="form-group">
<label for="place_type">City/Province</label>
<select name="place_type">
<option value="place_type">-Please Select One-</option>
<?php if(count($getPlacetype)):?>
<?php foreach($getPlacetype as $getplacetype):?>
<option value=
<?php echo $getplacetype->place_id;?>>
<?php echo $getplacetype->place_type;?>
<?php echo $getplacetype->place_price;?><span> PHP Shipping
Fee</span>
</option>
<?php endforeach;?>
<?php else:?>
<?php endif;?>
</select>
</div>
<button class="btn btn-primary btn-block"
name="profile">Proceed</button>
</div>
</form>
</div>
【问题讨论】:
-
问题是?您面临哪些错误?预期的结果是什么? ...?
-
有没有其他方法可以添加多个动态数据来查看,我面临的错误是我的 $custom_errors 变量变成了未定义的索引。
标签: php codeigniter