这是我尝试构建的内容的链接:http://postimg.org/image/9mgm6l9hj/
这是我的INSERT查询功能
function register_hangout($register_hangout_data) {
array_walk($register_hangout_data, 'array_sanitize');
$hangout_fields = '`' . implode('`, `', array_keys($register_hangout_data)) . '`';
$hangout_data = '\'' . implode('\', \'', $register_hangout_data) . '\'';
mysql_query("INSERT INTO hangouts ($hangout_fields) VALUES ($hangout_data)");
}
这里是代码,截至目前,它确实将我重定向到hangout.php?成功,但并没有回应#34; Successssss"或插入DB:
if (empty($_POST) === false) {
$required_fields = array('title','dd' ,'mm','yyyy', 'hour', 'minutes', 'location', 'aim', 'description');
foreach($_POST AS $key=>$value) {
if (empty($value) && in_array($key, $required_fields) === true) {
$errors[] = 'Fields marked with an asterisk are required.';
break 1;
}
}
print_r($errors);
}
?>
<?php
if (isset($_GET['success']) && empty($_GET['success'])) {
echo 'Successssssss.';
} else {
// there's one curly brace after the html form tied to this else right above
if (empty($_POST) === false && empty($errors) === true) {
//insert hangout data in mysql database
$register_hangout_data = array(
'title' => $_POST['title'],
'dd' => $_POST['dd'],
'mm' => $_POST['mm'],
'yyyy' => $_POST['yyyy'],
'hour' => $_POST['hour'],
'minutes' => $_POST['minutes'],
'location' => $_POST['location'],
'aim' => $_POST['aim'],
'description' => $_POST['description']
);
register_hangout($register_hangout_data);
header('Location: hangout.php?success');
// exit
}
elseif (empty($errors) === false) {
//output errors
echo output_errors($errors);
}
我无法理解为什么它们甚至没有插入数据库,更不用说使用正确的整数函数,清理,正确的日期时间函数和格式,所以请帮我解决我的实际问题在深入探讨我应该对此代码做些什么之前。