0

If a user is trying to log in with an account thats not confirmed or if the password is incorrect it'll come up with a little error box to tell them when the page reloads.

When the login script is run and I try to log into an account that isn't confirmed yet I return it with this url

signin.php?error=no_confirm

When the page reloads however it has the correct url but nothing happens! Do I have the code below set up correctly?

<?php
$error = $_GET['error'];

echo $error;

 if ($error) {
 if($error == 'mismatch') {
    echo "
<div class='alert alert-danger' role='alert'>
  <strong>Oh snap!</strong> You need to confirm your account before you sign 
in!
</div>
";
} elseif ($error == 'no_confirm') {
echo "
<div class='alert alert-danger' role='alert'>
  <strong>Oh snap!</strong> Youre username or password was incorrect.
</div>
";
} else {
echo "";
}
 } else {
    echo "nov";
 }

?>
cosmichero2025
  • 1,029
  • 4
  • 14
  • 37

4 Answers4

1

Remove the if ($error) { } and change it to if(isset($error)) { }

And make sure that your GET request is right:

.php?error=mismatch
getl0st
  • 342
  • 1
  • 10
  • I did that but it gave the same result as before... nothing :( – cosmichero2025 Apr 22 '17 at 20:29
  • Hey I just tried to do a basic on my page below the error display php code and its not outputing anything what would be the cause of this? Also var_dump doesn't work or anything else im confused about this – cosmichero2025 Apr 22 '17 at 20:39
  • Try to output all errors with `error_reporting(E_ALL); ini_set('display_errors', '1');` – getl0st Apr 22 '17 at 20:41
  • Its already enabled its just ignoring the php tags but the ones at the top and bottom for the include header.php and footer.php all work as well as the script for the form – cosmichero2025 Apr 22 '17 at 20:42
  • Put the error reporting on those pages too, might be a typo on those pages or maybe a more serious error that is causing your page to fail – getl0st Apr 22 '17 at 20:44
  • OMG IM DUM literally had the php on the wrong page i edited i had it on the registration page not the login page! – cosmichero2025 Apr 22 '17 at 20:44
  • Heres a check for helping me anyway XD – cosmichero2025 Apr 22 '17 at 20:45
0

Ok you don't set your page in utf-8 and it is just like a text file try to save it again

Osama
  • 2,912
  • 1
  • 12
  • 15
  • No I want to help you I see your comment to another answer when you said that it display the code instead of the result of not all your page do that why this page only do it ask yourself this question – Osama Apr 22 '17 at 20:51
  • You'll need to add this to your server configuration: AddType application/x-httpd-php .php that is assuming you have installed php properly, which may not be the case since it doesn't work where it normally would immediately after installing. It is entirely possible that you'll also have to add the php so/dll to your apache config using a LoadModule directive (usually in httpd.conf) – Osama Apr 22 '17 at 20:56
0

Hello your code is working for me, but also i wrote alternative way for you, you can try that way :

<?php
$error = $_GET['error'];

echo $error;


if (preg_match('/mismatch/',$error))
{
    echo "<div class='alert alert-danger' role='alert'>
  <strong>Oh snap!</strong> You need to confirm your account before you sign 
in!
</div>";
}

if (preg_match('/no_confirm/',$error))
{
    echo "<div class='alert alert-danger' role='alert'>
  <strong>Oh snap!</strong> Youre username or password was incorrect.
</div>";
}
?>
L. P.
  • 113
  • 11
-1

Try to use a double " instead of single ' $error = $_GET["error"];

Osama
  • 2,912
  • 1
  • 12
  • 15