login script !HELP!

Gestart doorJordyvc6 reacties56 weergaven

7 berichten · pagina 1 van 1

Jordyvc

Lid · Topicstarter

Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Beste,
ik heb een probleem met mijn script.
ik heb een account aangemaakt in mijn database,
maar waneer ik inlog gaat hij nietmeer verder.

Mijn login script

<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>


Dan heb ik ook een checklogin.php, en ik denk dat daar de fout zit, maar ik weet niet zeker, en hier het script:

[COLOR= #0000BB]<?php
$host[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$username[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"root"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$password[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"Mijn wachtwoord"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$db_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"DB Naam"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$tbl_name[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"Table naam"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #FF8000]// Connect to server and select databse.[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$host"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"$username"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"$password"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot connect"[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$db_name"[/COLOR][COLOR= #007700])[/COLOR]or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"cannot select DB"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #FF8000]// username and password sent from form [/COLOR]
[COLOR= #0000BB]$myusername[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]myusername[/COLOR][COLOR= #007700]];[/COLOR] 
[COLOR= #0000BB]$mypassword[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]mypassword[/COLOR][COLOR= #007700]];[/COLOR] 

[COLOR= #FF8000]// To protect MySQL injection (more detail about MySQL injection)[/COLOR]
[COLOR= #0000BB]$myusername[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$myusername[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$mypassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mypassword[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$myusername[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$myusername[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$mypassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mypassword[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"SELECT * FROM $tbl_name WHERE username=$myusername and password=$mypassword"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #FF8000]// Mysql_num_row is counting table row[/COLOR]
[COLOR= #0000BB]$count[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// If result matched $myusername and $mypassword, table row must be 1 row[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #FF8000]// Register $myusername, $mypassword and redirect to file "login_success.php"[/COLOR]
[URL="http://www.php.net/session_register"]session_register[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"myusername"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/session_register"]session_register[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"mypassword"[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"location:login_success.php"[/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]"Wrong Username or Password"[/COLOR][COLOR= #007700];
}[/COLOR]
?>


En daar blijft hij steken, maar ik heb dan nog een laatste script, login_succes.php
maar die komt helemaal ni, de pagina blijft ook wit!


[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/session_is_registered"]session_is_registered[/URL][COLOR= #007700]([/COLOR]myusername[COLOR= #007700])){[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"location:main_login.php"[/COLOR][COLOR= #007700]);
}[/COLOR]
?>

<html>
<body>
Login Successful,
</body>
</html>


En dit was het. als iemand mij kan helpen,
alvast bedankt.
0
Berichten
28
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Gatverdamme, nee! Je werkt met een verouderde PHP script dat soweiso erg onveilig is!
Dat staat trouwens ook op de PHP.net website:

Quote:
This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.

Niet doen dus! Als je een simpel login systeem zoekt, werk dan eventueel met ElementSoft 0.1.0.2, dat is een ledensysteem die uit dezelfde functies bestaat. Hij is door mij gemaakt, ruim anderhalf jaar geleden, er zitten nog enorme fouten in, maar het werkt wel, en veilig is hij ook.

Downloadlink.

Je moet het Habbo er wel even uithalen, maar dat moet niet moeilijk zijn, toch? Je kan trouwens ook PHPMenno add-ons erop aansluiten. wink
0
Jordyvc

Lid · Topicstarter

Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Itobias,
Bedankt voor de hulp. Dus het dus gewoon dat ik een te oude versie van PHP gebruik?
En bedankt voor de download link. thumbsup
Een ledensysteem is dat dan hetzelfde als een gewoon simpel inlogsysteem?

Alvast bedankt nerd
//Itobias,

Ik heb nog een vraag, als ik dan op registreren druk, en ik registreer mij
dan staat er dat ik nu kan inloggen.
Maar als ik dan inlog dan komt erop dat de gegevens fout zijn!

Moet ik dan nog eerst een database maken? of is het zo?bye
//2 berichten samengevoegd
0
Jordyvc

Lid · Topicstarter

Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Itobias,

Ik heb nog een vraag, als ik dan op registreren druk, en ik registreer mij
dan staat er dat ik nu kan inloggen.
Maar als ik dan inlog dan komt erop dat de gegevens fout zijn!

Moet ik dan nog eerst een database maken? of is het zo?
bye
0
Berichten
28
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je moet wel eerst de database maken, inderdaad. Anders kan hij het niet wegschrijven. Let niet op de fouten, want er zitten nogal grote bugs in yummie
0
Jordyvc

Lid · Topicstarter

Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey Itobias,

Ik heb een PM gestuurd nerd
Laterss
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nooit je $VARIABELE tussen "" zetten yummie
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