if ($count == 1){ //if username + pass is correct
$cookie_value = $user;
setcookie($cookie_name, $cookie_value, time() + (180), "/");
header("Location: personal.php");
}else{ //wrong info
echo "Gebruikersnaam of passwoord is niet juist!";
}
}else if (isset($_POST['register'])){
$user = $_POST['username'];
$pass = $_POST['password'];
$phash = sha1(sha1($pass."salt")."salt");
$sql = "INSERT INTO 'users' ( username, password) VALUES ($user', '$phash')'; ";
$result = myqli_query($conn, $sql);
}
?>
好的,当我尝试按下注册时,它不会将我带到personal.php,但它只是再次加载相同的东西。 (logreg.php,这个代码文件)
如果有人知道为什么标题不起作用,请告诉我!
编辑:现在的问题是它甚至无法执行过Isset。现在它甚至没有达到任何目的。代码:
if (isset($_POST['login']))
{
$user = $_POST['username'];
$pass = $_POST['password'];
$phash = sha1(sha1($pass."salt")."salt"); //password: not visible
$sql = "SELECT 'username' FROM 'users' WHERE username ='$user' AND password='$phash'; "; //fetching database
$result = myqli_query($conn, $sql); //check if login is right
$count = mysqli_num_rows($result);
if ($count == 1) //if username + pass is ok
{
$cookie_value = $user;
setcookie($cookie_name, $cookie_value, time() + (180), "/");
echo '<a href="personal.php">Continue</a>';
}
else
{
echo "username or password is incorrect";
}
}
else if (isset($_POST['register']))
{
$user = $_POST['username'];
$pass = $_POST['password'];
$phash = sha1(sha1($pass."salt")."salt");
$sql = "INSERT INTO 'users' ( username, password) VALUES ($user', '$phash')'; ";
$result = myqli_query($conn, $sql);
}
?>
答案 0 :(得分:1)
添加
exit();
之后
header("Location: personal.php");
并且会工作