Kleine Vragen Topic #2

Gestart doorKingunit3.067 reacties11.764 weergaven

3.068 berichten · pagina 64 van 205

Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Mysql_real_escape_string over je $_COOKIE, $_POST, $_GET
Had je trouwens zo kunnen vinden.......
Thank you, is dit goed?

$trim_user = trim($_POST[username]);
        $trim_password = trim($_POST[password]);
        $trim_email = trim($_POST[email]);
        
        $ent_user = htmlentities($trim_user);
        $ent_password = htmlentities($trim_password);
        $ent_email = htmlentities($trim_password);
        
        $safe_user = mysql_real_escape_string($ent_user);
        $safe_password = mysql_real_escape_string($ent_password);
        $safe_email = mysql_real_escape_string($ent_email);
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Htmlentities alleen bij echo
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Waarom niet in 1 regel?
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Waarom niet in 1 regel?
Hoe bedoel je in 1 regel?

Ze allemaal tegelijk htmlentities?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Sanderc schreef:
Eerdere citaten tonen
Aarclay schreef:
Waarom niet in 1 regel?
Hoe bedoel je in 1 regel?

Ze allemaal tegelijk htmlentities?
GEEN HTMLENTITIES!!! Dat doe je bij output, niet als je dingen insert.
Dit kan gewoon:

[COLOR= #0000BB]<?php

$username[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]));[/COLOR]

?>
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Raaoul schreef:
Eerdere citaten tonen
Sanderc schreef:
Eerdere citaten tonen
Aarclay schreef:
Waarom niet in 1 regel?
Hoe bedoel je in 1 regel?

Ze allemaal tegelijk htmlentities?
GEEN HTMLENTITIES!!! Dat doe je bij output, niet als je dingen insert.
Dit kan gewoon:

[COLOR= #0000BB]<?php

$username[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]));[/COLOR]

?>

Oh, nice, had ik niet door dat je gewoon functie in een functie kan doen.

Is dit trouwens een stukje relevante code (uit multisess) om in te loggen?

$check_login= mysql_query("SELECT * FROM leden WHERE username = ".$_POST[username]." AND password = ".md5($_POST[password])."");
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Ja.... maar was dat nog niet geescaped?
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Ja.... maar was dat nog niet geescaped?
Geescaped?

Hoe zet ik dat dan in een statement?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Ja... tegen sql injection...?
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heb het er in gezet.
Ik heb wat in elkaar geflanst, en toch zegt hij steeds dat de combinatie niet klopt;

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]"POST"[/COLOR][COLOR= #007700])
{[/COLOR]
    [COLOR= #0000BB]$check_login[/COLOR][COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" AND password = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]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]$check_login[/COLOR][COLOR= #007700])) 
    {[/COLOR]
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]login[/COLOR][COLOR= #007700]] =[/COLOR] true[COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000] Je bent ingelogd[/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] Deze combinatie is niet bekend[/COLOR][COLOR= #007700];
    }
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
?>
<form action="#" method="post">
Gebruikersnaam: <input type="text" name="username"><br/>
Wachtwoord:     <input type="password" name="password"><br/>
    <input type="submit" value="login">
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?>
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Weet je wel wat mysql_real_escape_string doet en wat SQL injection uberhaupt is? Als je dat weet, kan je je probleem oplossen.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Wat staat er in de database?
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Raaoul schreef:
Weet je wel wat mysql_real_escape_string doet en wat SQL injection uberhaupt is? Als je dat weet, kan je je probleem oplossen.
Nee, heb wat gegoogled, en op PHP tuts word het ook niet uitgelegd?
Aarclay schreef:
Wat staat er in de database?
Afbeelding
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Google even op SQL injection, lees wikipedia door en je begrijpt het.
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke ik zal het even lezen op de iPad, en dan kijk ik morgen verder even naar het script en hopen dat het lukt. Bedankt
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