我的表单邮件中有两个字段&密码。
我正在尝试从单一表单进行注册
条件是,如果您已注册,他将登录,否则他将被注册。
无法获得回应响应
<?php
include_once('connection.php');
include_once('functions.php');
$username = $_GET['username'];
$password = $_GET['password'];
$response=array();
// Check if that username is already exists.
$find_user = mysqli_query($conDB,"SELECT * FROM `users_info` WHERE `username` = '".$username."'");
if (mysqli_num_rows($find_user) != 0) $error[] = "That username is already exist.";
if (empty($error)){
$hashed_password = sha1($password);
// Check if submitted info is correct or not.
$check = mysqli_query($conDB,"SELECT * FROM `users_info` WHERE `username` = '".$username."' AND `password` = '".$hashed_password."'");
if (mysqli_num_rows($check) == 1) {
$code="login_success";
array_push($response,array("code"=>$code,"email"=>$username));
echo json_encode($response);
} else if (empty($error)){
$result = mysqli_query($conDB," INSERT INTO `users_info` (
`username`,
`password`
) VALUES (
'".$username."',
'".$hashed_password."'
)");
if(confirm_query($result)) {
redirect('login.php?signup=1');
}
} else {
$error[] = "Incorrect username or password.";
}
}
?>