Invoeren in database

Gestart doorLuukvdo12 reacties44 weergaven

13 berichten · pagina 1 van 1

Luukvdo

Lid · Topicstarter

Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo allemaal,

Ik ben bezig met het maken van mijn eigen forum-systeem waarvan de basis dit is.
Maar ik zit nu met een probleempje. Ik wil namelijk de posts in de database invoeren maar dan wel veilig en met behoud van alle oorspronkelijke tekens (bijv. , /, " enz.) maar ik heb geen idee hoe ik dit veilig kan doen en met behoud van alle tekens.

Ik hoop dat iemand me hiermee kan helpen.

Alvast bedankt!
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Mysql_real_escape_string() gewoon gebruiken, en dan dit dingetje EENMALIG includeren:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/* slash-stripper is gemaakt door Lennard van one2xs.com / one2apps.com */[/COLOR]
[COLOR= #007700]function[/COLOR] strip[COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/is_array"]is_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700]))
    {[/COLOR]
        
        [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/get_magic_quotes_gpc"]get_magic_quotes_gpc[/URL][COLOR= #007700]() ==[/COLOR] [COLOR= #0000BB]1[/COLOR] [COLOR= #007700]?[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR][COLOR= #007700]) :[/COLOR] [COLOR= #0000BB]$string[/COLOR][COLOR= #007700];
    
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        
        [COLOR= #0000BB]$nieuwe[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
        
        [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$string[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$key[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$value[/COLOR][COLOR= #007700])
        {[/COLOR]
            
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/is_array"]is_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]))
            {[/COLOR]
            
                [COLOR= #0000BB]$nieuwe[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]] =[/COLOR] [URL="http://www.php.net/get_magic_quotes_gpc"]get_magic_quotes_gpc[/URL][COLOR= #007700]() ==[/COLOR] [COLOR= #0000BB]1[/COLOR] [COLOR= #007700]?[/COLOR] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]) :[/COLOR] [COLOR= #0000BB]$value[/COLOR][COLOR= #007700];
            
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
                
                [COLOR= #0000BB]$nieuwe[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$key[/COLOR][COLOR= #007700]] =[/COLOR] strip[COLOR= #007700]([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]);
            
            }
        
        }[/COLOR]
        
        [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$nieuwe[/COLOR][COLOR= #007700];
    
    }
    
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/is_array"]is_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700]) >[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])[/COLOR]
    [COLOR= #0000BB]$_GET[/COLOR] [COLOR= #007700]=[/COLOR] strip[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/is_array"]is_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700]) >[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])[/COLOR]
    [COLOR= #0000BB]$_POST[/COLOR] [COLOR= #007700]=[/COLOR] strip[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700]);[/COLOR]
?>
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Je kunt hem ook nog verder versimpelen met array_map(). biggrin
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Maar dit werkt ook en had jij gemaakt yummie
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Ja, ik gebruik hem ook zo. emo
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Nou dan xd
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Maar dan kun je hem alsnog versimpelen. emo
0
Luukvdo

Lid · Topicstarter

Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nog even een vraagje: moet ik dan
strip(mysql_real_escape_string($var));


of
mysql_real_escape_string(strip($var));


doen?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Gewoon mysql_real_escape_string() verder niets meer aan doen smile
0
Luukvdo

Lid · Topicstarter

Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
o, okie
0
Luukvdo

Lid · Topicstarter

Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nog een vraagje: om het te echoen moet ik dan nog iets met htmlentities o.i.d. doen?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
html entities zou ik zoiezo als extra veiligheidje doen. Je moet nooit vertrouwen op wat de gebruiker invoerd yummie
0
Luukvdo

Lid · Topicstarter

Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt, het is inmiddels gelukt, er mag een slotje op
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