2
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);
}
?>
是什麼,而之前調用'header'回顯?如果任何頁面已經發送到客戶端,則不能執行標題重定向。 – Carcigenicate
當你設置了寄存器時,你還沒有給出頭部重定向 – jophab
你還有一個if,但是我沒有看到開頭if。你錯過了一些代碼段?你有沒有注意到你有其他的東西,之後呢? –