<?php
$conn = require "db.php";
$data=$_POST;
if ( isset($data['do_signup']) )
{
if ( trim($data['Name']) == '' )
{
$errors[] = 'Enter your name!';
}
if ( trim($data['Surname']) == '' )
{
$errors[] = 'Enter last name!';
}
if ( trim($data['email']) == '' )
{
$errors[] = 'Enter your email!';
}
if ( trim($data['telephon']) == '' )
{
$errors[] = 'Enter your phone!';
}
if ( $data['pass'] == '' )
{
$errors[] = 'Enter password!';
}
if ( $data['pass2'] != $data['pass'] )
{
$errors[] = 'Passwords do not match!';
}
if ( empty($errors) )
{//начало внесения данных в бд
if(isset($_POST['users']))
{
$Name = strip_tags(trim($_POST['Name']));
$Surname = strip_tags(trim($_POST['Surname']));
$email = strip_tags(trim($_POST['email']));
$telephon = strip_tags(trim($_POST['telephon']));
$pass = strip_tags(trim($_POST['pass']));
$sql = "INSERT INTO users (Name, Surname, email, telephon, pass) VALUES ('$Name', '$Surname', 'email', '$telephon', '$pass')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: errors" . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
echo "successfully completed";
}
} else
{
echo '<div style="color: red;">'.array_shift($errors).'</div><hr>';
}
}
?>
<form action="#" method="POST">
<p>
<p><strong>Name</strong>:</p>
<input type="text" name="Name" value="<?php echo @$data['Name']; ?>">
</p>
<p>
<p><strong>Surname</strong>:</p>
<input type="text" name="Surname" value="<?php echo @$data['Surname']; ?>">
</p>
<p>
<p><strong>Email</strong>:</p>
<input type="email" name="email" value="<?php echo @$data['email']; ?>">
</p>
<p>
<p><strong>Telephon</strong>:</p>
<input type="text" name="telephon" value="<?php echo @$data['telephon']; ?>">
</p>
<p>
<p><strong>Password</strong>:</p>
<input type="password" name="pass" value="<?php echo @$data['pass']; ?>">
</p>
<p>
<p><strong>Confirm the password</strong>:</p>
<input type="password" name="pass2" value="<?php echo @$data['pass']; ?>">
</p>
<p>
<button type="submit" name="do_signup">Signup</button>
</p>
</form>
$conn = require "db.php";
require "db.php";
$sql = "INSERT INTO users (Name, Surname, email, telephon, pass) VALUES ('$Name', '$Surname', 'email', '$telephon', '$pass')";
if (mysqli_query($conn, $sql))
$sql = mysqli_query($conn, "INSERT INTO users (Name, Surname, email, telephon, pass) VALUES ('$Name', '$Surname', 'email', '$telephon', '$pass')");
if ($sql){
//
}
required
тогда браузер сам скажет что поле не может быть пустым <input type="text" name="Name" value="<?php echo @$data['Name']; ?>" required>