Html 在进入codeigniter中的第二行之前,有没有办法将第一行设置为必填行?
我的看法是:Html 在进入codeigniter中的第二行之前,有没有办法将第一行设置为必填行?,html,codeigniter,Html,Codeigniter,我的看法是: <div class="col-md-3"> <div class="form-group"> <label>Employee Id</label> <input type="text" class="form-control" placeholder="Enter employee id" name="empid">
<div class="col-md-3">
<div class="form-group">
<label>Employee Id</label>
<input type="text" class="form-control" placeholder="Enter employee id" name="empid">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Employee Name</label>
<input type="text" class="form-control" placeholder="Enter employee name" name="empname">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Order Number</label>
<input type="number" class="form-control" placeholder="Enter order number" name="ordernumber" value="<?php echo $order_number;?>">
</div></div>
<div class="col-md-3">
<div class="form-group">
<label></label>
<a onclick="myFunctionfirst()" class="form-control">Proceed to order Create</a>
</div></div>
它抛出了一个错误,未定义索引empid欢迎使用stackoverflow。您可以做的是将输入保存为变量 然而,这种方法有点不安全。为了保护您可以使用的输入 一旦有了变量,只需检查变量是否为空
public function index()
{
$firstname = $_POST['firstname'];
If ($firstname != ""){
$this->load->model('invoice_model');
$data['stat']= $this->invoice_model->get_stationary();
$data['order_numbers']= $this->invoice_model->get_countnumber();
$data['order_number']= $data['order_numbers'][0]->count+1;
$data['page']='invoice/invoice_view';
$this->load->view("template",$data);
}
}
$\u POST
是数据的发送方式。这里他们解释了POST
和GET
“firstname”是输入的名称。在您的情况下,它是
,因此它应该是$\u POST['empid']
正在使用“提交”按钮发送数据。不要使用
标记,您也应该使用
标记,而是将输入包装在一个表单标记中。我在哪里使用它:它来自“将文本字段中的输入存储在PHP变量中”中,如果您需要任何其他解释,请为您编辑文章,就像我在controller中尝试的那样。获取错误消息:未定义索引:empid函数是否与html位于同一文件中?另外,你能把帖子编辑成你现在拥有的当前代码吗?这样我就知道你是否犯了任何错误了。公共函数index(){$empid=$\u post['empid'];if($empid==“”){$this->load->model('invoice\u model');$data['stat']=$this->invoice\u model->->get\u stational();$data['order\u number']=$this->invoice\u model->get\u countnumber();$data['order\u number']=$data['order\u number']][0]->count+1;$data['page']='invoice/invoice\u view';$this->load->view(“模板”,$data);}
public function index()
{
$firstname = $_POST['firstname'];
If ($firstname != ""){
$this->load->model('invoice_model');
$data['stat']= $this->invoice_model->get_stationary();
$data['order_numbers']= $this->invoice_model->get_countnumber();
$data['order_number']= $data['order_numbers'][0]->count+1;
$data['page']='invoice/invoice_view';
$this->load->view("template",$data);
}
}