2017-03-16 91 views
0

有了这个剧本,我必须输入用户名和密码才能访问 受保护的页面,如果它通过地址栏可能,我才明白,自动登录 ,我试图自动登录的网址

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

改变'$ _POST'到'$ _REQUEST'和你的网址是通过'http:/ /example.org/index.php?username=test&pw=test' – cmorrissey

回答

0

使用的网址:

http://example.org/index.php?username=myusername&pw=mypassword 

而更新脚本,以

<?php 
    session_start(); 
    $username = $_REQUEST['username']; 
    $password = $_REQUEST['pw']; 

    # continue as before 
+0

我做了上述改动,用$ _REQUEST改变$ _POST,可以使用immetto l'indirizzo http://example.org/index.php&username=myusername&pw=mypassword才不是 找到该网页,然后http://example.org/index.php?username=myusername&pw=mypassword,将我带回登录页面 – Mario

+0

对不起,在网址中输入错误。它应该是'http://example.org/index.php?username = myusername&pw = mypassword'。注意?在index.php之后并使用&vars之间的值 – brennan22