我有關於使用codeigniter進行表單驗證的問題。在用戶按下「提交」按鈕後,他們得到了預期的錯誤消息,但我也收到了錯誤消息(如下)。顯示錯誤消息的值是隱藏的。我不認爲這是罪魁禍首,因爲我嘗試了沒有隱藏值的語法,但它不起作用。我究竟做錯了什麼?感謝大家。應該隱藏表單驗證時的錯誤消息
錯誤消息
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: id
Filename: views/view_information.php
Line Number: 46
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: year
Filename: views/view_information.php
Line Number: 48
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: make
Filename: views/view_information.php
Line Number: 49
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: model
Filename: views/view_information.php
Line Number: 50
我查看
<style type="text/css" media="screen">
label{display: block}
</style>
<?php
echo (isset($error)) ? $error : "";
if(isset($carprices) && !is_null($carprices))
{
echo "Car# " . $carprices[0]->id . "<br />";
foreach ($carprices as $prices)
{
echo 'ID Of Vehicle: '.$prices->id.'<br>';
echo 'Year: '.$prices->year.'<br>';
echo 'Make: '.$prices->make.'<br>';
echo 'Model: '.$prices->model.'<br>';
echo '<hr>';
$id = $prices->id;
$year = $prices->year;
$make = $prices->make;
$model = $prices->model;
echo "$id".'<br>';
}
}
/*
foreach($updateprices as $row){
$id = $row->id;
$year = $row->year;
$make = $row->make;
$model = $row->model;
}
*/
echo form_open('site/form_validate_cars');
echo validation_errors();
$data = array(
'cardescription_id' => "$id",
'caruser_id' => "5", // hard-coded in
'year' => "$year",
'make' => "$make",
'model' => "$model"
);
echo form_hidden($data);
echo form_label('Value:','value');
$data = array(
'name' => 'value',
'id' => 'value',
'value' => set_value('value')
);
echo form_input($data);
// -----------------
echo form_label('Exterior Color:','exterior_color');
$data = array(
'name' => 'exterior_color',
'id' => 'exterior_color',
'value' => set_value('exterior_color')
);
echo form_input($data);
// -----------------
echo form_label('Interior Color', 'interior_color');
$data = array(
'name' => 'interior_color',
'id' => 'interior_color',
'value' => set_value('interior_color')
);
echo form_input($data);
// -----------------
echo form_label('Mileage:','mileage');
$data = array(
'name' => 'mileage',
'id' => 'mileage',
'value' => set_value('mileage')
);
echo form_input($data);
// -----------------
// removed echo-only <tr>s on fuel type, state and transmission
// -----------------
echo form_label('State:','state');
$data = array(
'Texas' => 'Texas',
'California' => 'California',
'Florida' => 'Florida',
'Nevada' => 'Nevada'
);
echo form_dropdown('State',$data,'California');
echo '<br>';
echo form_submit('SubmitDealerInfo','Submit!');
echo form_close();
?>
其中'LINES'是那些? –