Probleem in PHP code/database?

Gestart doorSemmiiee17 reacties17 weergaven

18 berichten · pagina 1 van 2

Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,
Ik was wat aan het scripten (tut aan het volgen. yummie).
En ik wil mijn systeempje (inlog systeempje) even testen, geeft het er een hoop errors aan.
Die heb ik dan gefixt.

Ik heb via mijn database een user aangemaakt,
username: semmiiee
password: test

Ik wil dan inloggen en dan geeft het aan "User doesnt exist!". Terwijl hij wel bestaat!
Er is ook geen error in de php code, ik snap niet wat er fout is. nopompom
PHP Code:

[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]/**! 
 * @author Semmiiee at One2xs.com
 * @copyright 2011
 */[/COLOR]

[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])
{[/COLOR]
    
  [COLOR= #0000BB]$connect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"semmiiee_sem"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"test"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Connect"[/COLOR][COLOR= #007700]);[/COLOR]
  [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"semmiiee_phplogin"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Find db"[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username=$username"[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #0000BB]$numrows[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
   
   [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR]numrows[COLOR= #007700]!=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700])
   {[/COLOR]
    
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
    {[/COLOR]
        [COLOR= #0000BB]$dbusername[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
        [COLOR= #0000BB]$dbpassword[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];
               
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbusername[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbpassword[/COLOR][COLOR= #007700])
    {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Youre in!"[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Incorrect password!"[/COLOR][COLOR= #007700];
    
    
    
    
   }[/COLOR]
   [URL="http://www.php.net/else"]else[/URL]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"That user doesnt exist!"[/COLOR][COLOR= #007700]);[/COLOR]
        
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Please enter Username and Password!"[/COLOR][COLOR= #007700]);[/COLOR]





?>


(Ik was een engelse tut aan het volgen op youtube.)

Scriptje: http://www.getclickmoney.nl/system/index.php, of klik Hier

Kan iemand me helpen?
- Semmiiee
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Isset toevoegen aan je if($username && $password){
of je gebruikt if($_SERVER[REQUEST_METHOD] == "POST"){
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb hem wat voor je opgeschoont:

[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]/**! 
 * @author Semmiiee at One2xs.com
 * @copyright 2011
 */[/COLOR]

[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])
{[/COLOR]
    
  [COLOR= #0000BB]$connect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"semmiiee_sem"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"test"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Connect"[/COLOR][COLOR= #007700]);[/COLOR]
  [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"semmiiee_phplogin"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Find db"[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #0000BB]$numrows[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
   
   [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR]numrows[COLOR= #007700]>[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700])
   {[/COLOR]
    
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
    {[/COLOR]
        [COLOR= #0000BB]$dbusername[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
        [COLOR= #0000BB]$dbpassword[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];
               
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbusername[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbpassword[/COLOR][COLOR= #007700])
    {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Youre in!"[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Incorrect password!"[/COLOR][COLOR= #007700];
    }
    
    
    
   }[/COLOR]
   [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"That user doesnt exist!"[/COLOR][COLOR= #007700]);
        }[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Please enter Username and Password!"[/COLOR][COLOR= #007700]);
}[/COLOR]




?>
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@^:
Blijft hetzelfde hoor. "User doenst exist".
0
Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]/**! 
 * @author Semmiiee at One2xs.com
 * @copyright 2011
 */[/COLOR]

[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])
{[/COLOR]
    
  [COLOR= #0000BB]$connect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"semmiiee_sem"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"test"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Connect"[/COLOR][COLOR= #007700]);[/COLOR]
  [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"semmiiee_phplogin"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Find db"[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #0000BB]$numrows[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #FF8000]// Hier stond daarjuist numrows, zonder $[/COLOR]
   [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700]>[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700])
   {[/COLOR]
    
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
    {[/COLOR]
        [COLOR= #0000BB]$dbusername[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
        [COLOR= #0000BB]$dbpassword[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];
               
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbusername[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbpassword[/COLOR][COLOR= #007700])
    {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Youre in!"[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Incorrect password!"[/COLOR][COLOR= #007700];
    }
    
    
    
   }[/COLOR]
   [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"That user doesnt exist!"[/COLOR][COLOR= #007700]);
        }[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Please enter Username and Password!"[/COLOR][COLOR= #007700]);
}[/COLOR]




?>


Die moet wel werken
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wouter schreef:
[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]/**! 
 * @author Semmiiee at One2xs.com
 * @copyright 2011
 */[/COLOR]

[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])
{[/COLOR]
    
  [COLOR= #0000BB]$connect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"semmiiee_sem"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"test"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Connect"[/COLOR][COLOR= #007700]);[/COLOR]
  [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"semmiiee_phplogin"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Find db"[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #0000BB]$numrows[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
   
   [COLOR= #FF8000]// Hier stond daarjuist numrows, zonder $[/COLOR]
   [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700]>[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700])
   {[/COLOR]
    
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
    {[/COLOR]
        [COLOR= #0000BB]$dbusername[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
        [COLOR= #0000BB]$dbpassword[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];
               
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbusername[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbpassword[/COLOR][COLOR= #007700])
    {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Youre in!"[/COLOR][COLOR= #007700];
        
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Incorrect password!"[/COLOR][COLOR= #007700];
    }
    
    
    
   }[/COLOR]
   [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"That user doesnt exist!"[/COLOR][COLOR= #007700]);
        }[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Please enter Username and Password!"[/COLOR][COLOR= #007700]);
}[/COLOR]




?>
Die moet wel werken
heartHet werkt. Alleen als ik inlog krijg ik Youre in1 ik maak nieuw account aan, krijg ik Youre in2.
Hoe haal ik dat nummer weg, dat is de ID van het account maar dat wil ik er niet hebben.
Maar bedankt Wouter smile.
0
Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Nee hoor, dat is niet je ID. Dat is het aantal keren dat de gebruiker voorkomt in de database.
Op regel 47 zie je staan:
echo $numrows;

dat is om te tonen hoeveeel keer hij in de database staat. Doe die regel weg en hij zal het niet meer zeggen
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wouter schreef:
Nee hoor, dat is niet je ID. Dat is het aantal keren dat de gebruiker voorkomt in de database.
Op regel 47 zie je staan:
echo $numrows;

dat is om te tonen hoeveeel keer hij in de database staat. Doe die regel weg en hij zal het niet meer zeggen

Bij 2e gebruiker is het andere naam en password. Toch staat er twee... confusedMaarja ik zal het eens even weghalen wink.
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik zou wel nog even mijn ding toevoegen:

if($_SERVER[REQUEST_METHOD] == "POST") {

dat is net even wat veiliger. Ook moet je even kijken (of google-en) naar mysql_real_escape_string. Omdat dat je variabelen veiliger maakt en zo ten minste het ergste kunt voorkomen. Ook zou ik zelf een die() gebruiken, omdat als je het later in een layout bouwt de rest van je pagina wat eronder komt dan weggaat. Succeswink
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kenzo schreef:
Ik zou wel nog even mijn ding toevoegen:

if($_SERVER[REQUEST_METHOD] == "POST") {

dat is net even wat veiliger. Ook moet je even kijken (of google-en) naar mysql_real_escape_string. Omdat dat je variabelen veiliger maakt en zo ten minste het ergste kunt voorkomen. Ook zou ik zelf een die() gebruiken, omdat als je het later in een layout bouwt de rest van je pagina wat eronder komt dan weggaat. Succeswink
Alsof ik snap waar ik dat moet neerzetten? emo.

PS: nieuw probleem!
Als ik member.php bekijk als ik ingelogt ben hoort er Welcome, JOUNAAM! te staan. bij mij dus:
Welcome, semmiiee!
Er staat gewoon: welcome, !

Login.php:

[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]/**!
 * @author Semmiiee at One2xs.com
 * @copyright 2011
 */[/COLOR]
 
  [URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]

[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])
{[/COLOR]
    
  [COLOR= #0000BB]$connect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"semmiiee_sem"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"test"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Connect"[/COLOR][COLOR= #007700]);[/COLOR]
  [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"semmiiee_phplogin"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Couldnt Find db"[/COLOR][COLOR= #007700]);[/COLOR]
  
   [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
  
   [COLOR= #0000BB]$numrows[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
  
   [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700]>[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700])
   {[/COLOR]
    
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
    {[/COLOR]
        [COLOR= #0000BB]$dbusername[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
        [COLOR= #0000BB]$dbpassword[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];
              
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbusername[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbpassword[/COLOR][COLOR= #007700])
    {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Youre in! <a href=member.php>Click hereto enter the Member Page.</a>"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]=[/COLOR][COLOR= #0000BB]$dbusername[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Incorrect password!"[/COLOR][COLOR= #007700];
    }
    
    
    
   }[/COLOR]
   [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"That user doesnt exist!"[/COLOR][COLOR= #007700]);
        }[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Please enter Username and Password!"[/COLOR][COLOR= #007700]);
}[/COLOR]




?>
Member.php:

[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]/**
 * @author 
 * @copyright 2011
 */[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Welcome,"[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]"!"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br><a href=logout.php>Logout</a>"[/COLOR][COLOR= #007700];[/COLOR]
?>
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je moet wel session_start() bovenaan zetten.
dus:

member.php:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #FF8000]/**
 * @author 
 * @copyright 2011
 */[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Welcome,"[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]"!"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br><a href=logout.php>Logout</a>"[/COLOR][COLOR= #007700];[/COLOR]
?>


en trouwens, het is volgens mij niet de bedoeling dat wij alles moeten voorkauwen.

Quote:
Alsof ik snap waar ik dat moet neerzetten? .emo
deze reactie lijkt me dan ook een beetje respectloos en jij wilt het leren en wij geven je tips en dan ga je zo reageren? wil je het überhaupt wel leren? zoja, probeer ook eens te google-en en niet uit iedereen zijn handje eten.
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kenzo schreef:
je moet wel session_start() bovenaan zetten.
dus:

member.php:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #FF8000]/**
 * @author 
 * @copyright 2011
 */[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Welcome,"[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]"!"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br><a href=logout.php>Logout</a>"[/COLOR][COLOR= #007700];[/COLOR]
?>
en trouwens, het is volgens mij niet de bedoeling dat wij alles moeten voorkauwen.

Quote:
Alsof ik snap waar ik dat moet neerzetten? .emo
deze reactie lijkt me dan ook een beetje respectloos en jij wilt het leren en wij geven je tips en dan ga je zo reageren? wil je het überhaupt wel leren? zoja, probeer ook eens te google-en en niet uit iedereen zijn handje eten.

Ik heb er nog een functie aan toe gevoegt, werd ook in de tut gedaan. ik heb session_start() er ook aan toegevoegd. Maar nu heb ik deze error:

Parse error: syntax error, unexpected T_IF in /home/semmiiee/domains/getclickmoney.nl/public_html/system/member.php on line 7

Member.php:

[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]/**
 * @author 
 * @copyright 2011
 */[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Welcome,"[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]"!"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br><a href=logout.php>Logout</a>"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"You must be logged in!"[/COLOR][COLOR= #007700]);   
}[/COLOR]


?>
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
if (isset($_SESSION[username])){

even proberen.
Ik zou toch maar gewoon session_start(); bovenaan zetten.
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kenzo schreef:
if (isset($_SESSION[username])){

even proberen.
Ik zou toch maar gewoon session_start(); bovenaan zetten.
Dat isset ding weet ik niet waar. Ik had session_start() er boven gezet. toen error. Ik was de puntkomma vergeten, maar nu werkt het. Bedankt! smile
Nu kan ik beginnen aan mijn Registersystem biggrin
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
oke mooi, succes.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren