0

So i started creating a basic website for a small project im working on. I took a 2 week break where i left everything in working condition. Decided to load up WAMP server today afternoon and as soon as i try to access my index file i get the error:

The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.

This is my index code.

<?php
session_start();
require_once('../Controller/loginController.php');

if(isset($_SESSION['user_session'])){
  header("location:accountSummary.php");
}
?> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet"  href="../Web/CSS/LoginStyle.css" type="text/css" /> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <title>Energy Checker: Login</title> </head> <body> <div id="login"> <div id="triangle"></div> <h1>Log in</h1> <form id="loginfrm" method="post"> <div id="logBtns"> <?php
        if(isset($error))
        {
          ?> <div class="loginAlert"> <?php echo $error; ?> </div> <?php
        }

        ?> <input type="text" id="txtAcc" name ="txtAccNum" placeholder="Account Number" required/> <br> <input type="password" id="txtPass" name ="txtPassword" placeholder="Password" maxlength="8" required/> <br> <input id="btn-login" type="submit" name="btn-login" value="Login">

        New User? Click <a href="register.php">here</a> to register.

      </div> </form> </div> </body> </html>

My Controller code:

<?php
require_once('../Model/loginModel.php');

$user = new Login();

if(isset($_POST['btn-login']))
{
    $accNum = strip_tags($_POST['txtAccNum']);
    $Password = strip_tags($_POST['txtPassword']);

    if($user->getLogin($accNum,$Password))
    {
        $user->redirect('../View/accountSummary.php');
    }
    else
    {
        $error = "Please check your login details";
    }   
}

?>

I have no idea whats caused this. My code hasnt changed at all. Any ideas?

Thanks!

3
Contributors
3
Replies
21
Views
1 Year
Discussion Span
Last Post by spud91
2

I may be wrong but I believe the issue you are having is in line 6 which reads:
header("location:accountSummary.php");

You should have some sort of path to the accountSummary.php file from document root. It may be that you were in a specific sub-directory when you were executing the script before and the php file was in the same sub-directory and was available for execution but you are running from a different location on the server now and it is no longer available without the relative path.

Examples I found always showed something like:

header("location: /accountSummary.php");
or
header("location: ../accountSummary.php");

And in every case there was a space between location: and the file name

I hope this helps and makes sense.

0

@rch1231 Ah i managed to get it working. The working of my accountSummary page has the correct MVC structure where the controller renders the view. I just had to change the location to access the accountSummary page through the controller directory.

Many Thanks!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.