表单提交后的处理

这样写会不会多此一举?
try{
$list = array();
$list[‘map_name’] = isset($_post[‘name’]) ? post_input($_post[‘name’]) : ”;
$list[‘map_city’] = isset($_post[‘city’]) ? post_input($_post[‘city’]) : ”;
$citylist = explode(‘,’, $list[‘map_city’]);
$list[‘map_city’] = isset($citylist[0]) ? $citylist[0] : ”;
$list[‘map_region’] = isset($citylist[1]) ? $citylist[1] : ”;
$list[‘map_district’] = isset($citylist[2]) ? $citylist[2] : ”;
$list[‘map_content’] = isset($_post[‘content’]) ? post_input($_post[‘content’]) : ”;
$list[‘map_lat’] = isset($_post[‘mlat’]) ? post_input($_post[‘mlat’]) : ”;
$list[‘map_lng’] = isset($_post[‘mlng’]) ? post_input($_post[‘mlng’]) : ”;
$list[‘map_crt_date’] = date(‘y-m-d h:i:s’, time());
isrequired($list[‘map_name’], ‘name is required’);
isrequired($list[‘map_city’], ‘city is required’);
isrequired($list[‘map_region’], ‘region is required’);
isrequired($list[‘map_district’], ‘district is required’);
isrequired($list[‘map_lat’], ‘location lat is required’);
isrequired($list[‘map_lng’], ‘location lng is required’);
isnumber($list[‘map_lat’], ‘location lat is not number’);
isnumber($list[‘map_lng’], ‘location lng is not number’);
$exclude = array();
$datatypes = array(‘str’, ‘str’, ‘str’, ‘str’, ‘str’, ‘float’, ‘float’, ‘none’);
$googlemap = googlemap::getinstance();
$googlemapid = $googlemap->inputinfo($list, $exclude, $datatypes);
if($googlemapid > 0){
goback(‘submit success!’, ‘show_googlemap.php’);
}else{
throw new exception(“insert is error”);
}
}catch (exception $e){
postexceptionlog(‘submit_googlemap.php : ‘ . $e->getmessage());
if(error_reporting()){
echo $e->getmessage();
exit;
}
goback(‘error’,’googlemap.php’);
}

回复讨论(解决方案)

我想会是 多此一举

$_post 也是数组

改这样吧。

Posted in 未分类

发表评论