如何在php中通过LAN ip访问localhost?

时间:2014-09-06 07:21:50

标签: php html lan

大家好我有三个简单的php页面login.phpprocess.phplogin_success.php。问题是我的{login.phpprocess.php存在1}} localhost:8080login_success.php位于同一个地区。我完全可以访问我的192.168.1.36:8080,但点按按钮时却没有显示login.php。我正在使用{ {1}}服务器,它安装在两个系统中。另一件事是我通过url直接访问login_success.php例如XAMPP。我的代码非常简单我的所有代码如下:

的login.php:

logout_success.php

Process.php:

http://192.168.1.36/xampp/logout_success.php

Login_success.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>

任何人都可以告诉我如何访问<?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!"; } ?> 页面。任何帮助都会非常明显。

2 个答案:

答案 0 :(得分: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/

另外,我想提醒您,这是如何不实施登录安全系统的一个不好的例子。

答案 1 :(得分:-2)

使用相对路径

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