s2ext

Bitte logg dich ein oder registriere dich.

Einloggen mit Benutzername, Passwort und Sitzungslänge
Erweiterte Suche  

Neuigkeiten:

Fehler und Spammer oder Probleme beim Login hier melden.

Autor Thema: PHP-Programm nimmt nur ersten User wahr!  (Gelesen 4011 mal)

Robo01

  • Newbie
  • *
  • Beiträge: 147
PHP-Programm nimmt nur ersten User wahr!
« am: September 08, 2008, 20:12:59 Nachmittag »

Mein PHP-Programm nimmt nur den ersten User aus der MySQL-Tabelle wahr:
Code: (php) [Auswählen]
  1. <?php</span></li><li style="" class="li2">[url=http://www.php.net/define]<span style="color: #000066;">define</span>[/url] <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'MYSQL_BENUTZER'</span>, <span style="color: #ff0000;">'root'</span> <span style="color: #66cc66;">&#41;</span>;</li><li style="" class="li2">[url=http://www.php.net/define]<span style="color: #000066;">define</span>[/url] <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'MYSQL_DATENBANK'</span>, <span style="color: #ff0000;">'mysqlpasswort'</span> <span style="color: #66cc66;">&#41;</span>;</li><li style="" class="li2"> </li><li style="" class="li1"><span style="color: #0000ff;">$db_link</span> = @[url=http://www.php.net/if]<span style="color: #b1b100;">if</span>[/url] <span style="color: #66cc66;">&#40;</span> ! <span style="color: #0000ff;">$db_link</span> <span style="color: #66cc66;">&#41;</span></li><li style="" class="li1"><span style="color: #66cc66;">&#123;</span></li><li style="" class="li2">  <span style="color: #808080; font-style: italic;">// hier sollte dann später dem Programmierer eine</span></li><li style="" class="li1">  <span style="color: #808080; font-style: italic;">// E-Mail mit dem Problem zukommen gelassen werden</span></li><li style="" class="li2">  <span style="color: #808080; font-style: italic;">// die Fehlermeldung für den Programmierer sollte</span></li><li style="" class="li1">  <span style="color: #808080; font-style: italic;">// das Problem ausgeben mit: mysql_error()</span></li><li style="" class="li2">  die<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'keine Verbindung zur Zeit möglich - später probieren '</span><span style="color: #66cc66;">&#41;</span>;</li><li style="" class="li1"><span style="color: #66cc66;">&#125;</span></li><li style="" class="li2"> </li><li style="" class="li1"><span style="color: #0000ff;">$db_sel</span> = [url=http://www.php.net/mysql_query]<span style="color: #000066;">mysql_query</span>[/url]<span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$sql</span> <span style="color: #66cc66;">&#41;</span>;</li><li style="" class="li1">[url=http://www.php.net/mysql_error]<span style="color: #000066;">mysql_error</span>[/url]<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</li><li style="" class="li2"><span style="color: #66cc66;">&#125;</span></li><li style="" class="li1"> </li><li style="" class="li2">[url=http://www.php.net/while]<span style="color: #b1b100;">while</span>[/url] <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$zeile</span> = [url=http://www.php.net/if]<span style="color: #b1b100;">if</span>[/url] <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'username'</span><span style="color: #66cc66;">&#93;</span><><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> and <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'passwort'</span><span style="color: #66cc66;">&#93;</span><><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></li><li style="" class="li1"> </li><li style="" class="li2">[url=http://www.php.net/else]<span style="color: #b1b100;">else</span>[/url]<span style="color: #66cc66;">&#123;</span></li><li style="" class="li1">[url=http://www.php.net/else]<span style="color: #b1b100;">else</span>[/url]<span style="color: #66cc66;">&#123;</span></li><li style="" class="li2"> </li><li style="" class="li1">[url=http://www.php.net/echo]<span style="color: #b1b100;">echo</span>[/url] <span style="color: #0000ff;">$zeile</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'übermich'</span><span style="color: #66cc66;">&#93;</span>;</li><li style="" class="li2">[url=http://www.php.net/echo]<span style="color: #b1b100;">echo</span>[/url] <span style="color: #0000ff;">$inhalt</span>;</li><li style="" class="li2">[url=http://www.php.net/echo]<span style="color: #b1b100;">echo</span>[/url] <span style="color: #ff0000;">'<a href="msql-logout.php">Logout</a>'</span>;</li><li style="" class="li2">exit;</li><li style="" class="li1"><span style="color: #66cc66;">&#125;</span>[url=http://www.php.net/echo]<span style="color: #b1b100;">echo</span>[/url] <span style="color: #ff0000;">'</span></li><li style="" class="li2"><span style="color: #ff0000;"><form action="mysql-passwortg.php" method=get enctype="text/plain"></span></li><li style="" class="li1"><span style="color: #ff0000;"> </span></li><li style="" class="li2"><span style="color: #ff0000;"><input type="Text" name="username" value="" size="30" maxlength="50"></span></li><li style="" class="li1"><span style="color: #ff0000;"> </span></li><li style="" class="li2"><span style="color: #ff0000;"><br /></span></li><li style="" class="li1"><span style="color: #ff0000;"><br /></span></li><li style="" class="li2"><span style="color: #ff0000;"> </span></li><li style="" class="li1"><span style="color: #ff0000;"><input type="password" name="passwort" value="" size="30" maxlength="50"></span></li><li style="" class="li2"><span style="color: #ff0000;"> </span></li><li style="" class="li1"><span style="color: #ff0000;"><br /></span></li><li style="" class="li2"><span style="color: #ff0000;"><br /></span></li><li style="" class="li1"><span style="color: #ff0000;"> </span></li><li style="" class="li2"><span style="color: #ff0000;"><input type="Submit" name="login" value="Login"></span></li><li style="" class="li1"><span style="color: #ff0000;"> </span></li><li style="" class="li2"><span style="color: #ff0000;"></form>'</span>;</li><li style="" class="li1"> </li><li style="" class="li2">exit;</li><li style="" class="li1"><span style="color: #66cc66;">&#125;</span></li><li style="" class="li2"><span style="color: #66cc66;">&#125;</span></li><li style="" class="li1"> </li><li style="" class="li2"> </li><li style="" class="li1">[url=http://www.php.net/echo]<span style="color: #b1b100;">echo</span>[/url] <span style="color: #0000ff;">$zeile</span><span style="color: #66cc66;">[</span><span style="color: #ff0000;">'übermich'</span><span style="color: #66cc66;">&#93;</span>;</li><li style="" class="li1">[url=http://www.php.net/echo]<span style="color: #b1b100;">echo</span>[/url] <span style="color: #0000ff;">$inhalt</span>;</li><li style="" class="li1">[url=http://www.php.net/echo]<span style="color: #b1b100;">echo</span>[/url] <span style="color: #ff0000;">'<a href="msql-logout.php">Logout</a>'</span>;</li><li style="" class="li1">exit;</li><li style="" class="li2"><span style="color: #66cc66;">&#125;</span>[url=http://www.php.net/echo]<span style="color: #b1b100;">echo</span>[/url] <span style="color: #ff0000;">'</span></li><li style="" class="li2"><span style="color: #ff0000;"><form action="mysql-passwortg.php" method=get enctype="text/plain"></span></li><li style="" class="li1"><span style="color: #ff0000;"> </span></li><li style="" class="li2"><span style="color: #ff0000;"><input type="Text" name="username" value="" size="30" maxlength="50"></span></li><li style="" class="li1"><span style="color: #ff0000;"> </span></li><li style="" class="li2"><span style="color: #ff0000;"><br /></span></li><li style="" class="li1"><span style="color: #ff0000;"><br /></span></li><li style="" class="li2"><span style="color: #ff0000;"> </span></li><li style="" class="li1"><span style="color: #ff0000;"><input type="password" name="passwort" value="" size="30" maxlength="50"></span></li><li style="" class="li2"><span style="color: #ff0000;"> </span></li><li style="" class="li1"><span style="color: #ff0000;"><br /></span></li><li style="" class="li2"><span style="color: #ff0000;"><br /></span></li><li style="" class="li1"><span style="color: #ff0000;"> </span></li><li style="" class="li2"><span style="color: #ff0000;"><input type="Submit" name="login" value="Login"></span></li><li style="" class="li1"><span style="color: #ff0000;"> </span></li><li style="" class="li2"><span style="color: #ff0000;"></form></span></li><li style="" class="li1"><span style="color: #ff0000;">'</span>;</li><li style="" class="li2">exit;</li><li style="" class="li1"><span style="color: #66cc66;">&#125;</span></li><li style="" class="li2"><span style="color: #66cc66;">&#125;</span></li><li style="" class="li1"><span style="color: #000000; font-weight: bold;">?>
  2.  
Ich weiß nicht was ich falsch mache!  xD
« Letzte Änderung: September 09, 2008, 21:16:23 Nachmittag von Robo01 »
Gespeichert

banane

  • Newbie
  • *
  • Beiträge: 290
    • http://www.eliswebspace.de.vu
Re: PHP-Programm nimmt nur ersten User wahr!
« Antwort #1 am: September 09, 2008, 14:55:44 Nachmittag »

session_start(); muss immer ganz am anfang stehen, davor darf nichts sein (nicht mal eine leerzeile, ein <html>-tag o.ä.)
« Letzte Änderung: Januar 01, 1970, 01:00:00 Vormittag von Guest »
Gespeichert
Keine Signatur. Klickt trotzdem bitte auf diesen Link<br>
Bitte wendet euch mit S2Ext an McLeaf, nicht an mich!

Robo01

  • Newbie
  • *
  • Beiträge: 147
Re: PHP-Programm nimmt nur ersten User wahr!
« Antwort #2 am: September 10, 2008, 16:02:37 Nachmittag »

Klapt immer noch nicht, das Problem ist eben dass der erste user in der mysql-Datenbank überprüft wird sonst keiner. Ich schätze dass es am while befehl liegt aber ich hab keine ahnung was der fehler ist. :cry_fox:
EDIT:
Hat sich erledigt. Neues Problem: Die while schleife geht auch weiter wenn der user schon angemeldet ist!:

Code: (php) [Auswählen]
  1. [url=http://www.php.net/mysql_fetch_array]mysql_fetch_array[/url]( $db_erg, MYSQL_ASSOC)) {
  2. [url=http://www.php.net/if]if[/url] (($_GET['username']==$zeile['username']) AND ($_GET['passwort']==$zeile['passwort'])) {
  3.  
  4. $_SESSION['angemeldet'] = 'ja';
  5.  
  6.  }[url=http://www.php.net/echo]echo[/url] ' <font color="red">Logindaten sind falsch!</font>';
  7. }
  8. }
  9.  
  10. [url=http://www.php.net/echo]echo[/url] $zeile['übermich'];
  11. [url=http://www.php.net/echo]echo[/url] $inhalt;
  12. [url=http://www.php.net/echo]echo[/url] '<a href="msql-logout.php">Logout</a>';
  13. exit;
  14. }[url=http://www.php.net/echo]echo[/url] '
  15. <form action="mysql-passwortg.php" method=get enctype="text/plain">
  16.  
  17. <input type="Text" name="username" value="" size="30" maxlength="50">
  18.  
  19. <br />
  20. <br />
  21.  
  22. <input type="password" name="passwort" value="" size="30" maxlength="50">
  23.  
  24. <br />
  25. <br />
  26.  
  27. <input type="Submit" name="login" value="Login">
  28.  
  29. </form>';
  30. }
  31. }
  32. exit;
Brauche dringend hilfe! Ich habe schon alles ausprobiert. :()
« Letzte Änderung: Januar 01, 1970, 01:00:00 Vormittag von Guest »
Gespeichert

Firzen

  • Newbie
  • *
  • Beiträge: 21
    • http://neon-polas.de/
Re: PHP-Programm nimmt nur ersten User wahr!
« Antwort #3 am: September 10, 2008, 22:58:47 Nachmittag »

Schon mit break; anstelle von exit; in der Schleife probiert?
« Letzte Änderung: Januar 01, 1970, 01:00:00 Vormittag von Guest »
Gespeichert

Robo01

  • Newbie
  • *
  • Beiträge: 147
Re: PHP-Programm nimmt nur ersten User wahr!
« Antwort #4 am: September 11, 2008, 18:33:46 Nachmittag »

Ja aber es ändert nichts daran dass das Loginfeld drei mal oder mehr(abhängig von anzahl an usern) angezeigt wird. :cry_fox:
« Letzte Änderung: Januar 01, 1970, 01:00:00 Vormittag von Guest »
Gespeichert

banane

  • Newbie
  • *
  • Beiträge: 290
    • http://www.eliswebspace.de.vu
Re: PHP-Programm nimmt nur ersten User wahr!
« Antwort #5 am: September 11, 2008, 22:27:08 Nachmittag »

kein wunder, du hast schließlich die ausgabe des formulars IN der while-schleife...
« Letzte Änderung: Januar 01, 1970, 01:00:00 Vormittag von Guest »
Gespeichert
Keine Signatur. Klickt trotzdem bitte auf diesen Link<br>
Bitte wendet euch mit S2Ext an McLeaf, nicht an mich!

Robo01

  • Newbie
  • *
  • Beiträge: 147
Re: PHP-Programm nimmt nur ersten User wahr!
« Antwort #6 am: September 12, 2008, 16:38:25 Nachmittag »

Ja ich weiß aber ich weiß nicht wie ichs anders machen könnte.  =D
« Letzte Änderung: Januar 01, 1970, 01:00:00 Vormittag von Guest »
Gespeichert

banane

  • Newbie
  • *
  • Beiträge: 290
    • http://www.eliswebspace.de.vu
Re: PHP-Programm nimmt nur ersten User wahr!
« Antwort #7 am: September 13, 2008, 11:51:47 Vormittag »

schließ die schleife einfach vorher und häng das formular NACH der schleife nochmal an ( mit if($_SESSION...) natürlich!)
« Letzte Änderung: Januar 01, 1970, 01:00:00 Vormittag von Guest »
Gespeichert
Keine Signatur. Klickt trotzdem bitte auf diesen Link<br>
Bitte wendet euch mit S2Ext an McLeaf, nicht an mich!

Dicker

  • Newbie
  • *
  • Beiträge: 97
Re: PHP-Programm nimmt nur ersten User wahr!
« Antwort #8 am: September 15, 2008, 16:18:24 Nachmittag »

Zitat von: "banane"
session_start(); muss immer ganz am anfang stehen, davor darf nichts sein (nicht mal eine leerzeile, ein <html>-tag o.ä.)

Wollte ich nochmal korrigieren, wie es oben stand war es vollkommen korrekt

korrekt:
Code: (text) [Auswählen]
  1. <?php</li><li style="" class="li2">session_start();</li><li style="" class="li1">?>

Code: (text) [Auswählen]
  1. <?php</li><li style="" class="li2">// oh hai</li><li style="" class="li1">session_start();</li><li style="" class="li2">?>

Code: (text) [Auswählen]
  1. <?php</li><li style="" class="li2">$yay "a chiken";</li><li style="" class="li1">session_start();</li><li style="" class="li2">?>

nicht korrekt:
(Fehler: HTTP-Headers already sent. Sobald die erste Zeile Text rausgeht werden natürlich auch die Header verschickt)

[Meh, das Beispiel mit der Leerzeile will der mir net machen, wird aus dem Code-Tag rausgetrimmt]

Code: (text) [Auswählen]
  1. <!-- Kommentar zählt manchmal doch -->
  2. <?php</li><li style="" class="li1">session_start();</li><li style="" class="li2">?>

Code: (text) [Auswählen]
  1. <html>
  2. <?php</li><li style="" class="li1">session_start();</li><li style="" class="li2">?>
« Letzte Änderung: Januar 01, 1970, 01:00:00 Vormittag von Guest »
Gespeichert