使用此脚本,我必须输入用户名和密码才能访问 受保护的页面,我会理解是否可以通过地址栏登录 我自动尝试了
Http://example.org/index.php&myusername&mypassword
但我无法访问它可以自动从地址栏登录。
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['pw'];
if($username == "" or $password == ""){
echo "Non puoi accedere senza Username o password";
}else if($username == "" and $password == ""){
echo "Non puoi accedere senza Username e password";
}else{
// configure your username and password
if($username == "test" AND $password == "test"){
echo "Benvenuto $username";
echo "<a href='http://www.example.com'>Vai alla pagina</a>";
}else{
echo "Accesso negato, questo username non esiste";
}
}
function loggeduser($username){
}
?>
答案 0 :(得分:0)
我建议使用$ _REQUEST来请求地址栏中的变量。
答案 1 :(得分:0)
使用网址:
http://example.org/index.php?username=myusername&pw=mypassword
将脚本更新为
<?php
session_start();
$username = $_REQUEST['username'];
$password = $_REQUEST['pw'];
# continue as before