我有一张表格。当用户提交时,值应插入数据库中。只有一个$ _POST的值没有插入数据库中,但其他$ _POST正在正确插入。
如何解决这个问题?
HTML:
<input type="text" name="position" value="<?php echo $_POST['jobTitle']; ?>" id="position" required/>
PHP代码段:
$firstName = $middleName = $lastName = $email = $mobile = $resume = $position = $message = $attachment_id = $locations = "";
if(isset($_POST['submit'])){
$firstName = isset($_POST['firstName']) ? $_POST['firstName'] : '';
$middleName = isset($_POST['middleName']) ? $_POST['middleName'] : '';
$lastName = isset($_POST['lastName']) ? $_POST['lastName'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$mobile = isset($_POST['mobile']) ? $_POST['mobile'] : '';
$locations = isset($_POST['locations_list']) ? $_POST['locations_list'] : '';
$position = isset($_POST['jobTitle']) ? $_POST['jobTitle'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
if( ! empty($_FILES)){
$file=$_FILES['resumeFile'];
$attachment_id = upload_user_file($file);
}
$sql=$wpdb->query("INSERT INTO resume_databank(submit_time,last_name,first_name,middle_name,mobile_number,email,location,position,message,process_resume,attachment_resume_id) VALUES (now(),'$lastName','$firstName','$middleName','$mobile','$email','$locations','$position','$message','No','$attachment_id')");
}
exit();
答案 0 :(得分:4)
更改此部分
$position = isset($_POST['jobTitle']) ? $_POST['jobTitle'] : '';
到
$position = isset($_POST['position']) ? $_POST['position'] : '';
因为在你的表格中。您的字段名称为position
,$_POST['jobTitle'];
只是一个值