Jump to content

System error on login failure


onjegolders
 Share

Recommended Posts

Am seeing an error when failing with a login which I've never seen before.

"Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Error has been logged."

 

If login succeeds the page redirects fine but when I input an incorrect combination, rather than an else statement I get the above error.

 

The code I'm using is:

 


<?php

$out = "<h6>Please login below</h6>";

if($input->post->username && $input->post->pass) {

    $user = $sanitizer->username($input->post->username);
    $pass = $input->post->pass; 

    if ($session->login($user, $pass)) {
        $session->redirect("/");
    } else {
    	$out = "<h6>Sorry, your login credentials were not correct.</h6>";
    }
}

?>

<?php include("./header.inc"); ?>

<div id="login" class="content">
	<div class="row">
		<div class="large-5 columns">
			
			<?php echo $out; ?>

			<form action="./" method="post">
				<label for="username">Username</label>
				<input type="text" name="username" autofocus>
				<label for="pass">Password</label>
				<input type="password" name="pass">
				<input type="submit" value="Login" class="btn grey">
			</form>
		</div> <!-- /.large-5 columns -->
	</div> <!-- /.row -->
</div> <!-- /#login.content -->

<?php include("./footer.inc"); ?>

EDIT: Just to say there are no errors in errors.txt

Link to comment
Share on other sites

Whenever you get that error message, go and enable debug mode in /site/config.php, just so that you can get some more details as to what is happening. Double check that your homepage template has the guest role enabled. No need to sanitize the password btw. 

  • Like 1
Link to comment
Share on other sites

You're overwriting the $user variable here:

$user = $sanitizer->username($input->post->username);

Use a different name, e.g. $u

Btw happens to me too sometimes with $page or $pages :)

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...