<?php
require "db.php";
$data=$_POST;
if ( isset($data['do_signup']) )
{
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 = mysqli_query($conn, "INSERT INTO users (Name, Surname, email, telephon, pass) VALUES ('$Name', '$Surname', 'email', '$telephon', '$pass')");
if ($sql)
{
echo "New record created successfully";
} else {
echo "Error: errors" . $sql . "<br>" . mysqli_error($sql);
}
mysqli_close($conn);
}
} 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']; ?>"required>
</p>
<p>
<p><strong>Surname</strong>:</p>
<input type="text" name="Surname" value="<?php echo @$data['Surname']; ?>"required>
</p>
<p>
<p><strong>Email</strong>:</p>
<input type="email" name="email" value="<?php echo @$data['email']; ?>"required>
</p>
<p>
<p><strong>Telephon</strong>:</p>
<input type="text" name="telephon" value="<?php echo @$data['telephon']; ?>"required>
</p>
<p>
<p><strong>Password</strong>:</p>
<input type="password" name="pass" value="<?php echo @$data['pass']; ?>"required>
</p>
<p>
<p><strong>Confirm the password</strong>:</p>
<input type="password" name="pass2" value="<?php echo @$data['pass']; ?>"required>
</p>
<p>
<button type="submit" name="do_signup">Signup</button>
</p>
</form>
<?php
$host = 'localhost'; // адрес сервера
$database = ''; // имя базы данных
$user = ''; // имя пользователя
$password = ''; // пароль
$conn = mysqli_connect($host, $user, $password, $database) or die("Error connection");
mysqli_query($conn,"set names utf8") or die ("<br>Invalid query: " . mysqli_error());
?>
<?php
$host = ''; // адрес сервера
$database = ''; // имя базы данных
$user = ''; // имя пользователя
$password = ''; // пароль
$link = mysqli_connect($host, $user, $password, $database)
or die("Ошибка " . mysqli_error($link));
mysqli_close($link);
?>