Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> logowanie - postgresql
domelpl
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 6.01.2007

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


Witam,
Wiem że jest pełno tematów na forum o logowaniu, przeczytałem chyba wszystkie ale nadal nie moge poradzić sobie z logowaniem
Zamieszczam mój prosty skrypt i z góry przepraszam za głupie błędy ale jestem początkujący
Błagam pomuszcie mi

index.html
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
  3. <title>strona testowa</title>
  4.  
  5. <STYLE type="text/css">
  6. .logowanie {font-family: sans-serif; font-size: 12pt; margin:4em;}
  7. .tytul {font-family: Home Sweet Home; font-size: 15pt; margin:3em;}
  8. </head>
  9. <SPAN class="tytul"><br><br><div align="center"><STRONG>Witaj w programie lojalnosciowym</STRONG></div></SPAN>
  10. <SPAN class="logowanie"><br><br><div align="center"><form action="logowanie.php" method="post">
  11. <p>Login<input type="text" name="form_log" /></p>
  12. <p>Haslo<input type="password" name="form_pass" /></p>
  13. <p><input type="submit" value="Zaloguj" /></p>
  14. </form></div></SPAN>
  15.  
  16. </body>
  17. </html>



logowanie.php
  1. <?php
  2. function laczenie()
  3. {
  4. $db=pg_connect('host=localhost dbname=test user=domel');
  5. //if ($db) {
  6. //echo 'polaczenie udane';}
  7. //else {
  8. //echo 'polaczenie nieudane';}
  9. }
  10.  
  11. $lacz=laczenie(); echo '<br>';
  12. //$login = 'domel';
  13. //$password = 'lotus';
  14. $log = $_POST['form_log'];
  15. $pass = $_POST['form_pass'];
  16.  
  17. $login = ('select login from users where login='$log';');
  18. $wyk1 = pg_query($login);
  19. $password = ('select haslo from users where haslo='$pass';');
  20. $wyk2 = pg_query($password);
  21.  
  22. if ($log == $wyk1 && $pass == $wyk2)
  23. { 
  24. $user=$_POST['form_log'];
  25. echo('<br><div align="center">Witaj '.$user.'</div>'); 
  26. } 
  27. else 
  28. { 
  29. echo('Bledny login lub haslo'); 
  30. } 
  31. //-----------------------------------------------------------------------------------------
  32.  
  33. ?>


Zapomniałem dodać w czym problem a więc: po wpisaniu danych do formularza przerzuca mnie na stronke "logowanie.php"
i na tym koniec nic sie nie dzieje. Wcześniej gdy miałem z góry ustalony login i hasło bez łączenia z bazą to wszystko działało
Jeszcze raz proszę o pomoc i wyrozumiałość
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
BORG
post
Post #2





Grupa: Zarejestrowani
Postów: 68
Pomógł: 0
Dołączył: 18.12.2006

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


Jezeli masz
  1. <form action="logowanie.php">

To cie przenosi na te stronke. Mozesz w logowanie.php dodac
  1. location.href = 'index.html';
  2. </script>

Wtedy z logowanie.php cie przekieruje na inna stronke, mozesz tez zrobic plik index.php
  1. <?
  2. include("logowanie.php");
  3. if($_POST['action'] == 'login')
  4. {
  5. loguj($_POST['form_login'], $_POST['form_pass']);
  6. }
  7. ?>
  8. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  9. <html>
  10. <head>
  11. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
  12. <title>strona testowa</title>
  13.  
  14. <STYLE type="text/css">
  15. .logowanie {font-family: sans-serif; font-size: 12pt; margin:4em;}
  16. .tytul {font-family: Home Sweet Home; font-size: 15pt; margin:3em;}
  17. </STYLE>
  18. </head>
  19. <body>
  20. <SPAN class="tytul"><br><br><div align="center"><STRONG>Witaj w programie lojalnosciowym</STRONG></div></SPAN>
  21. <SPAN class="logowanie"><br><br><div align="center"><form action="index.php" method="post">
  22. <p>Login<input type="text" name="form_log" /></p>
  23. <p>Haslo<input type="password" name="form_pass" /></p>
  24. <input type="hidden" name="action" value="login">
  25. <p><input type="submit" value="Zaloguj" /></p>
  26. </form></div></SPAN>
  27.  
  28. </body>
  29. </html>


i plik logowanie.php:

  1. <?php
  2. function laczenie()
  3. {
  4. $db=pg_connect('host=localhost dbname=test user=domel');
  5. //if ($db) {
  6. //echo 'polaczenie udane';}
  7. //else {
  8. //echo 'polaczenie nieudane';}
  9. }
  10. function loguj($log, $pass)
  11. {
  12. $lacz=laczenie(); echo '<br>';
  13. //$login = 'domel';
  14. //$password = 'lotus';
  15.  
  16.  
  17. $login = ('select login from users where login='$log';');
  18. $wyk1 = pg_query($login);
  19. $password = ('select haslo from users where haslo='$pass';');
  20. $wyk2 = pg_query($password);
  21.  
  22. if ($log == $wyk1 && $pass == $wyk2)
  23. { 
  24. $user=$_POST['form_log'];
  25. echo('<br><div align="center">Witaj '.$user.'</div>'); 
  26. } 
  27. else 
  28. { 
  29. echo('Bledny login lub haslo'); 
  30. } 
  31. //-----------------------------------------------------------------------------------------
  32. }
  33. ?>


Powinno dzialac, chyba ze cos zchrzanilem (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

Ten post edytował BORG 6.01.2007, 16:50:10
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 14.10.2025 - 06:57