我新的PHP和我寫了這個代碼:PHP代碼不工作 - 如果和重定向到一個頁面
<?php
$usernametest="Testing";
$passwordtest="TestingPass";
if (isset($_POST['submit']))
{
if ((isset($_POST['username']) == $usernametest) && (isset($_POST['password']) == $passwordtest))
{ include ('templates/main.php');
}
else
{
echo "please enter the correct username and password combination";
}
exit();
}
?>
我做了兩個文本框和一個提交按鈕,我希望用戶被定向到另一個頁面如果用戶名等於Testing並且密碼等於TestingPass,並且如果用戶沒有輸入正確的組合,我希望網站說用戶名和密碼不正確。另外,我應該在哪裏準確地粘貼此代碼?在文本框代碼上方?
「在此處輸入代碼」 的一部分? –
使用header()函數進行重定向,如下所示:header('location:templates/main.php'); –