Вот код php.Я также новичок в php и запросах, является ли мой запрос неправильным, потому что или любая логическая ошибка, потому что данные не отражаются в таблице, названной как пользователь.registration.php также включает.Трудно понять новичку в php, вы можете точно определить ошибку.
<?php
//connect to the database
$db=mysqli_connect('localhost','root', '','register') or die("not connected");
if($db){
echo "connection s";
}
global $errors;
global $sql;
//if next bustton is clicked
if(isset($_POST['Next'])){
$first =mysql_real_escape_string($_POST['first name']);
$last =mysql_real_escape_string($_POST['last name']);
$regno =mysql_real_escape_string($_POST['reg no']);
//all fields filled
if(empty($first)){
array_push($errors,"First name is required");
}
if(empty($last)){
array_push($errors,"Last name is required");
}
if(empty($regno)){
array_push($errors,"Registration number is required");
}
//error free then there are no errors,save it in database
if(count($errors)==0){
$sql="insert into users (first name, last name, regno) values ('$first', '$last', '$regno')";
$query=mysqli_query($db,$sql);
if($query){
echo "query inserted";
}
}
}
?> Здесь main registration.php start
<?php include('server.php'); ?>
<!DOCTYPE html>
<html>
<head>
<title>Registration</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="wrap">
<h2>Book Bank Registration</h2>
<form action="registration.php" method="POST">
<?php include('errors.php'); ?>
<div class="form-group">
<label>First Name</label>
<input type="text" class="form-control" name="firstname">
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" class="form-control" name="lastname">
</div>
<div class="form-group">
<label>Registration No</label>
<input type="text" class="form-control" name="regno">
</div>
<div class="form-group">
<!--label for="next">Next</label-->
<input type="submit" value="Next" class="form-control" name="next">
</div>
</form>
</div>
</body>
</html>
здесь метод POST