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!

Recommended Answers

All 3 Replies

Have you checked if you have blocked cookies in your browser for your site?

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.

@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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.