Problem with User authentication script

Problem with User authentication script

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

i have the index page where the login form is.But i have a problem because when i type the user and pass it relocated me in the same page-index.php.
i must to mansion, that i need a simple php login,not with database.
So i have a index page and when i login i want to give me IndexAdmin.php.I dont understand,it seem everything is OK,but still doesnt work.

here is the code:

<?php session_start();      $_SESSION['logged'] = 0;      if (isset($_POST['submit']))      {         if($_POST['username'] == "aaa" or  $_POST['password'] == "aaa")         {           $_SESSION['logged'] =1;           header ("Location:IndexAdmin.php");           }         else         { ?> <html> <head> ......>html code <form action="Index.php" method="post"> <input type="hidden" name="redirect"  value="<?php echo $_POST['redirect']; ?>"> <input type="text" name="username" size="10" tabindex="101"><br /> <input type="password" name="password" size="10" tabindex="102"> <input type="Submit" value="submit" name="Submit" size="10" tabindex="103"><br /> </form> .....>here is the rest of the html code that is not important <?php         } } else {   ?> <html> <head> ......html code <form action="Index.php" method="post"> <input type="hidden" name="redirect"  value="<?php echo $_GET['redirect']; ?>"> <input type="text" name="username" size="10" tabindex="101"><br /> <input type="password" name="password" size="10" tabindex="102"> <input type="Submit" value="submit" name="Submit" size="10" tabindex="103"><br /> </form> ......html code <?php } ?> </body> </html>

with the dots i mean that there is the rest of the html code like images etc...

and in the IndexAdmin.php page i have include "inc.auth.php" because if the user tries to type indexAdmin.php he will get that he must login to see this page
here is the inc.auth.php code

<?php session_Start();      if ($_SESSION['logged'] != 1)      {      $redirect = $_SERVER['PHP_SELF'];      header("Refresh: 5; URL=index.php?redirect=$redirect");      echo "u cant see this page, you must login<BR>";      echo "you will be redirected to the main page<br>";      echo "(if your browser doenst support this ,  <a href=\"index.php?redirect=$redirect\">click here</a>)";      die();     ?>



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • Blood  Male
  • Ugledni građanin
  • Pridružio: 26 Jul 2003
  • Poruke: 384
  • Gde živiš: Beograd

What error message do you get?



offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

I found the mistake after breaking my keyboard Smile

in the first IF statemant i wrote submit with all lower case

if (isset($_POST['submit']))

but in the form button i wrote with first upper case " name="Submit" "

and that was the error. i dont believe.I didnt know that i must write it exactly as in the if statemant.
Almost i was throwing my monitor out of my window but now.....huhhh, it's ok Smile

Ko je trenutno na forumu
 

Ukupno su 1012 korisnika na forumu :: 49 registrovanih, 9 sakrivenih i 954 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: -[CoA]-, 357magnum, 8u47, _Rade, A.R.Chafee.Jr., Asparagus, babaroga, Boris Bosiljčić, bufanje, cemix, Centauro, DENIRO, Dimitrise93, Duh sa sekirom, dzoni19, FileFinder, Georgius, h8propaganda, ILGromovnik, Istman, jackreacher011011, JOntra, Kubovac, kybonacci, ladro, laganini123, ljuba, Magistar78, maiden6657, Milometer, MiroslavD, misa1xx, mkukoleca, mnn2, muaddib, Nemanja.M, Panter, Posmatrac77OKB, RJ, sap, Shinobi, SlaKoj, stegonosa, VJ, vladulns, wolverined4, zziko, šumar bk2, Čivi