所以基本上已经有好几天了,为什么找不到为什么我的数据库没有任何价值,有人可以帮忙吗?
<!DOCTYPE html>
<html>
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$db = "employee";
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $db);
//Check connection
if($conn->connect_error){
echo "Connection Failed!";
}
if (isset($_POST['register-user']))
{
$username = $_POST['userName'];
$firstname = isset($_POST['firstName']);
$lastname = isset($_POST['lastName']);
$password = isset($_POST['password']);
$gender = isset($_POST['gender']);
$role = isset($_POST['role']);
// Check users input
$username = mysqli_real_escape_string($conn, $username);
$firstname = mysqli_real_escape_string($conn, $firstname);
$lastname = mysqli_real_escape_string($conn,$lastname);
$password = mysqli_real_escape_string($conn, $password);
$username = stripslashes($username);
$firstname = stripslashes($firstname);
$lastname = stripslashes($lastname);
$password = stripslashes($password);
$username = strip_tags($username);
$firstname = strip_tags($firstname);
$lastname = strip_tags($lastname);
$password = strip_tags($password);
$username = htmlspecialchars($username);
$firstname = htmlspecialchars($firstname);
$lastname = htmlspecialchars($lastname);
$password = htmlspecialchars($password);
$username = trim($username);
$firstname = trim($firstname);
$lastname = trim($lastname);
$password = trim($password);
$passhide = md5($password);
$insert="INSERT INTO `user` ( `username`, `firstname`, `lastname`, `password`, `gender`, `role`) VALUES ($username, , $firstname, $lastname, $password, $gender, $role)";
if (mysqli_query($conn, $insert)){
echo "Data registered successfully";
}
else{
echo "Something went wrong. Try again later.";
}
}
mysqli_close($conn);
?>
<head>
<title>MAURIJOB | Registration Form</title>
<style type='text/css' link='css/style.css' rel='stylesheet'>
body{
margin-right: auto;
margin-right: auto;
width:610px;
font-family:'Arial';
}
#background2 {
width: 100%;
height: 100%;
position: fixed;
left: 0px;
top: 0px;
z-index: -1; /* Ensure div tag stays behind content; -999 might work, too. */
}
.stretch {
width:100%;
height:100%;
}
.wrap2 {
display: solid;
text-align: center;
width: 412px;
overflow: hidden;
margin-left: 450px;
margin-right: auto;
margin-top: 50px;
background: #fff;
border: 1px solid silver;
padding: 10px;
border-radius: 10px;
opacity: 0.7;
}
.wrap2:hover {
opacity: 1.0;
}
.wrap2 input.demoInputBox {
width: 400px;
height: 30px;
margin-bottom: 8px;
border-radius: 3px;
border: 1px solid silver;
padding: 5px;
font-size: 18px;
}
.error-message {
padding: 7px 10px;
background: #fff1f2;
border: #ffd5da 1px solid;
color: #d6001c;
border-radius: 4px;
}
.success-message {
padding: 7px 10px;
background: #cae0c4;
border: #c3d0b5 1px solid;
color: #027506;
border-radius: 4px;
}
.btnRegister {
padding: 10px 30px;
background-color: #2fcbe0;
border: 0;
color: #FFF;
cursor: pointer;
border-radius: 4px;
margin-left: 10px;
}
</style>
</head>
<body>
<div id="background2">
<img src="image/registerbackground.jpg" class="stretch" alt="" />
</div>
<div class="wrap2" id="wrap2">
<h2>Registration Form</h2>
<form id="frmRegistration" name="frmRegistration" method="POST" action="register2.php">
<input type="text" class="demoInputBox" name="userName"id="userName" required placeholder="User Name"><br/>
<input type="text" class="demoInputBox" name="firstName"id="firstName" required placeholder="First Name"><br/>
<input type="text" class="demoInputBox" name="lastName"id="lastName" required placeholder="Last Name"><br/>
<input type="password" class="demoInputBox" name="password"id="password" value="" required placeholder="Password"><br/>
<input type="password" class="demoInputBox" name="confirmPassword"id="confirmPassword" value="" required placeholder="Confirm Password"><br/>
Gender <input type="radio" name="gender" id="gender" value="Male">
Male
<input type="radio" name="gender" id="gender" value="Female">
Female<br/><br/>
<input type="radio" name="role" id="role" value="jobseeker">
Jobseeker
<input type="radio" name="role" id="role" value="Employer">
Employer<br/><br/>
<input type="checkbox" name="terms" id="box" required >I accept Terms and Conditions <br/><br/>
<input type="submit" name="register-user" value="Register" class="btnRegister">
<input type=button onClick="parent.location='login.html'" class="btnRegister"value='Login'>
</form>
</div>
<input type=button onClick="parent.location='Homepage.html'" class="btnRegister"value='Back to Homepage'>
</body>
</html>
在提交时,它仅显示错误消息,如果未插入任何数据,并且我检查是否有任何错别字,甚至在网站上进行交叉检查,但都会进行错误检查,但仍然没有任何内容,我还是PHP的新手,还是学生,所以不要苛刻