我的代码不是将数据发送到数据库,但它让我有自己的错误,如数据库错误或其他什么。试过检查我的数据库它似乎是完美的。在post方法中,寄存器是按钮的名称
docker-1.13.1-22.gitb5e3294.fc26.x86_64
这是我的dbconnect,我已经对所有内容进行了双重检查,似乎我的代码中没有错误 dbconnect.php
<?php
if(isset($_POST['register']))
{
@$username=$_POST['username'];
@$password=$_POST['password'];
@$cpassword=$_POST['cpassword'];
@$role=$_POST['role'];
if($password==$cpassword)
{
$query = "SELECT * FROM usersample WHERE username='$username'";
//echo $query;
$query_run = mysqli_query($con,$query);
//echo mysql_num_rows($query_run);
if($query_run)
{
if(mysqli_num_rows($query_run)>0)
{
echo '<script type="text/javascript">alert("This Username Already exists.. Please try another username!")</script>';
}
else
{
$query = "INSERT INTO usersample(username,password,role)" ." values('$username','$password','$role')";
$query_run = mysqli_query($con,$query);
if($query_run)
{
echo '<script type="text/javascript">alert("User Registered.. Welcome")</script>';
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
header( "Location: index.php");
}
else
{
echo '<p class="bg-danger msg-block">Registration Unsuccessful due to server error. Please try later</p>';
}
}
}
else
{
echo '<script type="text/javascript">alert("DB error")</script>';
}
}
else
{
echo '<script type="text/javascript">alert("Password and Confirm Password do not match")</script>';
}
}
else
{
}
?>