<?php
$dbc = mysqli_connect('localhost','root','','user');
if(isset($_POST['submit'])){
$login=mysql_real_escape_string($dbc, trim($_POST['login']));
$password1=mysql_real_escape_string($dbc, trim($_POST['password1']));
$password2=mysql_real_escape_string($dbc, trim($_POST['password2']));
if(!empty($login) && !empty($password1) && (empty($password2) && ($password1 == $password2){
$query = "SELECT * FROM 'user' WHERE login ='$login'";
$data = mysqli_query($dbc,$query);
if(mysqli_num_rows($data) == 0){
$query = "INSERT INTO 'user' (login,password) VALUES ($login,md5($password1))";
mysqli_query ($dbc,$query);
echo "Вы успешно зарегестрированы!";
mysqli_close($dbc);
exit();
} else {
echo 'Логин уже существует!';
}
}
}
?>
<?php
$dbc = mysqli_connect('localhost', 'root', '', 'user');
if(isset($_POST['submit'])){
$login = mysql_real_escape_string($dbc, trim($_POST['login']));
$password1 = mysql_real_escape_string($dbc, trim($_POST['password1']));
$password2 = mysql_real_escape_string($dbc, trim($_POST['password2']));
if(!empty($login) && !empty($password1) && (empty($password2) && ($password1 == $password2))){
$query = "SELECT * FROM 'user' WHERE login ='$login'";
$data = mysqli_query($dbc, $query);
if(mysqli_num_rows($data) == 0){
$query = "INSERT INTO 'user' (login,password) VALUES ($login,md5($password1))";
mysqli_query($dbc, $query);
echo "Вы успешно зарегестрированы!";
mysqli_close($dbc);
exit();
}else{
echo 'Логин уже существует!';
}
}
}
?>