2014-09-06 99 views
-2

嗨,大家好,我有三个简单的PHP页面login.phpprocess.phplogin_success.php。问题是login.phpprocess.php存在于我的localhost:8080login_success.php出现在192.168.1.36:8080但同样lan.I我完全访问我的login.php但点击按钮,它没有显示login_success.php。我使用的是XAMPP服务器,它安装在两个系统中。另一件事是我通过url直接访问logout_success.phphttp://192.168.1.36/xampp/logout_success.php。我的代码很简单我所有的代码如下:如何在php中通过局域网ip访问localhost?

的login.php:

<form action="process.php" method="POST"> 
    username:<input type="text" name="username"/> 
      <br/> 
    password:<input type="password" name="pass"/> 
      <br/> 
      <input type="submit" value="Login!"/> 
</form> 

Process.php:

<?php 
    $username = $_POST['username']; 
    $password = $_POST['pass']; 

    if($username == 'test' AND $password == 'test') 
    { 
     header('Location : http://192.168.1.36/xampp/logout_success.php'); 
    } 
    else 
    { 
     echo "You have not logged in,username or password is incorrect!"; 
    } 
?> 

Login_success.php:

<html> 
    <body> 
    Logout Success<br> 
    Thanks for using the Captive Portal... 
    </body> 
</html> 

灿任何人告诉我如何访问login_success.php page.Any帮助将是非常可观的。

+0

当您点击按钮时,它确切地显示了什么? – 2014-09-06 07:25:01

+0

显示空白页面。 – CodeSniper 2014-09-06 07:44:26

+0

login_succes.php为什么在其他地方? – 2014-09-06 08:43:46

回答

1
得到

头呼叫内的空白空间。

变化

header('Location : http://192.168.1.36/xampp/logout_success.php'); 

header('Location: http://192.168.1.36/xampp/logout_success.php'); 

整个代码:

的index.php

<form action="process.php" method="POST"> 
    username:<input type="text" name="username"/> 
      <br/> 
    password:<input type="password" name="pass"/> 
      <br/> 
      <input type="submit" value="Login!"/> 
</form> 

process.php

<?php 
    $username = $_POST['username']; 
    $password = $_POST['pass']; 

    if($username == 'test' AND $password == 'test') 
    { 
     header('Location: login_success.php'); 
    } 
    else 
    { 
     echo "You have not logged in,username or password is incorrect!"; 
    } 
?> 

login_success.php

<html> 
<head></head> 
    <body> 
    Logout Success<br> 
    Thanks for using the Captive Portal... 
    </body> 
</html> 

确保文件名是正确的(小写)。我已经在我的测试服务器上尝试过了,它似乎工作。 (http://jagmit.co.uk/test/php_login/

此外,我只是想提醒你,这是一个不好的例子,如何不实现登录安全系统。

+0

它删除空白后将我带到所需的地址,但它不显示“logout_success.php”的内容,它显示“网页不可用” '。我应该在'logout_success.php'中添加一些东西吗?! – CodeSniper 2014-09-06 09:24:44

+0

刚刚更新了我的文章。另外,您的php重定向是'logout_success.php',但是您的文件被称为'login_success.php'。 – jagmitg 2014-09-06 10:32:35

+0

工作感谢 – CodeSniper 2014-09-06 11:39:51

-2

使用相对路径

header('Location : ./logout_success.php'); 
+0

它没有工作:( – CodeSniper 2014-09-06 08:00:13

相关问题