我是新的OOP PHP中,我仍然在學習,我有一個表單位置名稱填充通過JQuery/HTML形式使用下拉字段具有相同的名稱,我的問題是當我嘗試在MySQL數據庫中插入,我沒有選擇的值,php數組下拉字段沒有插入到數據庫mysql
<div id="NCR" class="drop-down-show-hide">
<div class="field">
<label for="region"> NCR </label>
<select name="region" id="ncr region">
<option value="">-- Choose --</option>
<option value="1"> Region 1 </option>
<option value="2"> Region 2 </option>
<option value="3"> Region 3 </option>
</select>
</div>
</div>
<div id="CAR" class="drop-down-show-hide">
<div class="field">
<label for="field"> CAR </label>
<select name="region" id="car region">
<option value="">-- Choose --</option>
<option value="4"> Region 4 </option>
<option value="5"> Region 5 </option>
<option value="6"> Region 6 </option>
</select>
</div>
</div>
<div id="region3" class="drop-down-show-hide">
<div class="field">
<label for="region"> CAMANABA </label>
<select name="region" id="camanaba region">
<option value="">-- Choose --</option>
<option value="7"> Region 7 </option>
<option value="8"> Region 8 </option>
<option value="9"> Region 9 </option>
</select>
</div>
</div>/HTML
PHP
if(Token::check(Input::get('token'))){
$validate = new Validate();
$validation = $validate->check($_POST, array(
'apz_account' => array(
'required' => true
),
'api_account' => array(
'required' => true
),
'wupos_tid' => array(
'required' => true
),
));
if($validation->passed()){
// check APZ account
$agent = DB::getInstance()->get('agent', array('apz_account', '=', Input::get('apz_account')));
if(!$agent->count()){
// check API account
$agent = DB::getInstance()->get('agent', array('api_account', '=', Input::get('api_account')));
if(!$agent->count()){
$agent = new Agent();
try {
$agent->createAgentAccount(array(
'apz_account' => Input::get('apz_account'),
'api_account' => Input::get('api_account'),
'wupos_tid' => Input::get('wupos_tid'),
'region' => Input::get('region'),
'registered' => date('Y-m-d H:i:s'),
));
// print_r($agent);
// Session::flash('success', 'You have registered successfully.');
// Redirect::to('../../index.php');
} catch(Exception $e){
die($e->getMessage());
}
} else {
echo Input::get('api_account'), ' account is already exists';
}
} else {
echo Input::get('apz_account'), ' account is already exists';
}
} else {
foreach ($validation->errors() as $error) {
echo $error, '<br>';
}
}
}
請指點。謝謝
請觀看本次講座:https://www.youtube.com/watch?v=z_LxkB-Pgf0 –