Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
This code, of course, was written by a gray mare with her left hoof. I have not seen so many errors per unit of code for a long time
Well, at least like this:
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$dbc = mysqli_connect('127.0.0.1', 'root', '', 'buy_sell_base');
mysqli_set_charset($dbc, $charset);
if(isset($_POST['submit'])){
$username = mysqli_real_escape_string($dbc, trim($_POST['username']));
$password1 = trim($_POST['password1']);
$password2 = trim($_POST['password2']);
if($username && $password1 && $password1 == $password2){
$query = "SELECT * FROM signup WHERE username ='$username'";
$data = mysqli_query($dbc, $query);
if(mysqli_num_rows($data) == 0){
$password = password_hash($password1, PASSWORD_DEFAULT);
$query = "INSERT INTO signup (username, password) VALUES ('$username', '$password')";
mysqli_query($dbc, $query);
echo 'Все готово';
exit();
}
else{
echo 'Пользователь уже зарегистрирован';
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question