-2

Hi guys i have three simple php pages login.php,process.php and login_success.php.The problem is that login.php and process.php is present in my localhost:8080 but login_success.php is present at 192.168.1.36:8080 but on same lan.I am perfectly accessing my login.php but on clicking button it is not displaying login_success.php.I am using XAMPP server and it is installed in both the systems.The other thing is that i am accessing logout_success.php through url directly for e.g. http://192.168.1.36/xampp/logout_success.php. My code is very simple All my code is as follows:

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> 

Can anyone tell me how to access login_success.phppage.Any help would be greatly appreciable.

CodeSniper
  • 493
  • 3
  • 12
  • 23

2 Answers2

0

Got a white space within the header call.

Change

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

to

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

Entire Code:

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> 

Make sure the file names are right (lowercase). I have tried it on my test server and it seems to work. (http://jagmit.co.uk/test/php_login/)

Also, i just would like to remind you that this is a bad example of how NOT to implement a login security system.

jagmitg
  • 4,236
  • 7
  • 25
  • 59
  • It takes me to the required address after removing the whitespace but it is not displaying contents of `logout_success.php` ,it shows `web page is not available`.Should i need to add something in `logout_success.php`? ! – CodeSniper Sep 06 '14 at 09:24
  • just updated my post. Also, your php redirect is `logout_success.php` but your file is called `login_success.php` – jagmitg Sep 06 '14 at 10:32
-2

Use relative paths

header('Location : ./logout_success.php');
seppy
  • 11
  • 2