Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]System logowania
wiemcojeem
post 25.02.2018, 19:48:03
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 25.02.2018

Ostrzeżenie: (0%)
-----


Cześć.. Mam problem - Otóż, nie wiem co napisałem źle, ale gdy wprowadzam dane do formularza logowania - on niestety nie działa. Prosiłbym o pomoc.
Kod:
  1. <?php
  2. //include config
  3. require_once('../includes/config.php');
  4.  
  5.  
  6. //check if already logged in
  7. if( $user->is_logged_in() ){ header('Location: index.php'); }
  8. ?>

  1. <!doctype html>
  2. <html lang="en">
  3. <meta charset="utf-8">
  4. <title>Admin Login</title>
  5. <link rel="stylesheet" href="../style/normalize.css">
  6. <link rel="stylesheet" href="../style/main.css">
  7. </head>
  8.  
  9. <div id="login">

  1. <?php
  2.  
  3. //process login form if submitted
  4. if(isset($_POST['submit'])){
  5.  
  6. $username = trim($_POST['username']);
  7. $password = trim($_POST['password']);
  8.  
  9. if($user->login($username,$password)){
  10.  
  11. //logged in return to index page
  12. header('Location: index.php');
  13.  
  14.  
  15. } else {
  16. $message = '<p class="error">Wrong username or password</p>';
  17. }
  18.  
  19. }//end if submit
  20.  
  21. if(isset($message)){ echo $message; }
  22. ?>

  1. <form action="" method="post">
  2. <p><label>Username</label><input type="text" name="username" value="" /></p>
  3. <p><label>Password</label><input type="password" name="password" value="" /></p>
  4. <p><label></label><input type="submit" name="submit" value="Login" /></p>
  5. </form>
  6.  
  7. </div>
  8. </body>
  9. </html>
Go to the top of the page
+Quote Post
viking
post 25.02.2018, 19:50:26
Post #2





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


A co konkretnie oznacza że nie działa? Włączyłeś wyświetlanie błędów?


--------------------
Go to the top of the page
+Quote Post
Kshyhoo
post 25.02.2018, 19:52:27
Post #3





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Witaj na Forum, zapoznaj się z zasadami tu panującymi. Na początek: podaj więcej szczegółów, bo "nie działa" to bardzo subiektywne pojęcie.


--------------------
Go to the top of the page
+Quote Post
trueblue
post 25.02.2018, 19:54:37
Post #4





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


Co jest w zmiennej $user?


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 16.04.2024 - 23:48