能帮我看看吗?数据无法保存在数据库中并且没有任何功能,我已经定义了数据库
$conn = mysqli_connect(HOST,USER,PASSWORD,DATABASE); if (isset($_POST['posts'])) {
$type = mysqli_real_escape_string($conn,$_POST['ServiceType']); $status = mysqli_real_escape_string($conn,$_POST['Status']); $skill = mysqli_real_escape_string($conn,$_POST['Skill']); $location = mysqli_real_escape_string($conn,$_POST['Location']); $credit = mysqli_real_escape_string($conn,$_POST['Credit']);
//Make sure the User fill up the form correctly. if (empty($type)){ array_push($errors, "Please fill up the service type"); } if (empty($status)){ array_push($errors, "Please fill up your status"); } if (empty($skill)){ array_push($errors, "Please fill up your skill"); } if (empty($location)){ array_push($errors, "Please fill up your location"); } if (empty($credit)){ array_push($errors, "Please put your credit"); } 如果将$ _SESSION ['Login']放在if语句外,则会显示出来,但是在将if语句放到里面后,将无法显示,并且在我将外键添加为UserId后也无法保存数据库的整个功能。
if(count($errors) == 0) { //Foreign Key as UserId $LogIn = $_SESSION['Login']; echo $LogIn; $sql = "INSERT INTO post(ServiceType, status, skill, location, credit, UserId) VALUES ('$type','$status','$skill','$location','$credit', '$LogIn')"; mysqli_query($conn, $sql); $_SESSION['type'] = $type; header('location: http://localhost/Post.php'); } else { echo "Failed"; } } 有任何错误吗?因为它无法保存到数据库并且没有显示任何错误
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。