PHP //

Gestart doorDigital5 reacties18 weergaven

6 berichten · pagina 1 van 1

Digital

Lid · Topicstarter

Berichten
326
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,
Ik heb ergens een foutje gemaakt. maar ik word er niet wijs uit?

Script

[COLOR= #0000BB]<?PHP[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]

[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strip_tags"]strip_tags[/URL][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][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]))[/COLOR] [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Vul alle waarden in op <a href="login.php">het formulier</a>.[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$db[/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]root[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]****[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"world"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$db[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]SELECT name,password FROM users WHERE name= . $username .  && password= . $password . [/COLOR][COLOR= #007700])) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
{[/COLOR]

    [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]login[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]yes[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]location: index.php[/COLOR][COLOR= #007700]);

}[/COLOR]

[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]

?>
    <!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
    <head>
    <title>Redirect</title>
    </head>
    <body>
    Sorry, maar deze combinatie van gebruikersnaam en wachtwoord is niet toegestaan.
    </body>
    </html>
[COLOR= #0000BB]<?PHP[/COLOR]
[COLOR= #007700]}[/COLOR]
?>


Error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:Users****DesktopWebserverootloggedin.php on line 11


(Lennard-edit: spoilers door code-tags vervangen)
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Je kunt geen enkele quotes gebruiken zonder ze te escapen als je die ook aan de buitenkant van je regel gebruikt zegmaar.

Probeer hem zo eens:

[COLOR= #0000BB]<?PHP[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]

[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strip_tags"]strip_tags[/URL][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][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]) ||[/COLOR] [URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]))[/COLOR] [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Vul alle waarden in op <a href="login.php">het formulier</a>.[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$db[/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]root[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]****[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"world"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$db[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$logincheck[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT name,password FROM users WHERE name = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$username[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]" && password = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$password[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]() ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
{[/COLOR]

    [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]login[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]yes[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]location: index.php[/COLOR][COLOR= #007700]);

}[/COLOR]

[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]

?>
    <!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
    <head>
    <title>Redirect</title>
    </head>
    <body>
    Sorry, maar deze combinatie van gebruikersnaam en wachtwoord is niet toegestaan.
    </body>
    </html>
[COLOR= #0000BB]<?PHP[/COLOR]
[COLOR= #007700]}[/COLOR]
?>


En doe even mysql_real_escape_string() om $username heen, is wat veiliger.
0
Digital

Lid · Topicstarter

Berichten
326
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maar dan klopt if(mysql_num_rows() == 1) toch niet meer?

Dan krijg je zoiets als dit , Warning: Wrong parameter count for mysql_num_rows() in C:Users****DesktopWebserverrootloggedin.php on line 13
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Oja, moet je er even dit van maken:
if(mysql_num_rows($logincheck) == 1)
0
Digital

Lid · Topicstarter

Berichten
326
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt smile+1
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Digital schreef:
Maar dan klopt if(mysql_num_rows() == 1) toch niet meer?

Dan krijg je zoiets als dit , Warning: Wrong parameter count for mysql_num_rows() in C:Users****DesktopWebserverrootloggedin.php on line 13
Daarvoor heeft dat ook niet gewerkt hoor 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