这个php代码写在我文件的末尾
<?php
if(isset($_POST['submit']))
{
$Jobtitle = $_POST['jobtitle'];
$Firstname = $_POST['firstname'];
$Lastname = $_POST['lastname'];
$Name=$Firstname+$Lastname;
$Sin = $_POST['sin'];
$Phone = $_POST['phone'];
$Email = $_POST['email'];
$Address = $_POST['address'];
$Postal = $_POST['postal'];
$State = $_POST['state'];
$Country = $_POST['country'];
$Skill = $_POST['skill'];
$Owntransport = $_POST['owntransport'];
$ADate = $_POST['a-date'];
$Workpermit = $_POST['workpermit'];
$Daysavailable = $_POST['days-available'];
$Strength = $_POST['strength'];
$eFirstname = $_POST['efirstname'];
$eLastname = $_POST['elastname'];
$eName=$eFirstname+$eLastname;
$ePhone = $_POST['ephone'];
$query=" INSERT INTO `general`(`jobtitle`, `name`, `sin`, `pno`, `email`, `address`, `doc`, `skills`, `transport`, `avadate`, `authorize`, `days`, `strength`, `ename`, `ephone`) VALUES ('{$Jobtitle}','{$Name}','{$Sin}','{$Phone}','{$Email}','{$Address}','{$Postal}','{$State}','{$Country}','{$Skill}','{$Owntransport}','{$ADate}','{$Workpermit}','{$Daysavailable}','{$Strength}','{$eName}','{$ePhone}')";
// $query = "INSERT INTO info (name,password,gender,hobby,phone no,dob,message) VALUES ('{$Name}','{$Password}','{$Gender}','{$Hobby}','{$Phone}','{$Dob}','{$Message}')";
$result = mysql_query($query);
if($result)
{
echo "data entered";
}
unset($_POST);
}
else{
echo "error in entering data";
}
&GT;
这是按钮标签
<button type="button" class="btn btn-primary"name="submit"value="submit" id="submit">Submit</button>
这是表格标签
<form method="post" id="contactform" action="#" role="form">
连接.php文件给我连接到数据库但我无法将数据存储在数据库中它给我的错误 未输入数据
答案 0 :(得分:1)
问题是,您正在使用15 columns
并尝试更新17 values
。
我认为您错过了state
和postal
列。
旁注:
还有两个问题:
mysql_*
扩展名已弃用,但在PHP 7中不可用。<强>建议:强>
使用mysqli_*
或PDO
作为第1点。
要进行调试,请始终在代码中使用活跃的PHP error_reprting
。