Reactie systeem

Gestart doorDylan15 reacties29 weergaven

16 berichten · pagina 1 van 2

Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Hoi, ik ben nu bezig met een reactie systeem, en ik heb nu al 2 problemen:
Probleem 1:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]] >=[/COLOR] [COLOR= #0000BB]25[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je reactie is te groot![/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];
    }[/COLOR]
?>


Als bij het vakje reactie heel veel tekens invul (meer dan 25 dus) staat er gewoon dat ie is geplaats.
Wat is hier mis mee?

Probleem 2:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]] ===[/COLOR] [COLOR= #0000BB]$woorduitdatabase[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt een verboden woord/zin in je reactie gezet, je reactie is dus niet geplaats. <br />[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];
    }[/COLOR]
?>


Als in de database bijv. Hoi staat en ik typ alleen Hoi in staat er wel "Je hebt een verboden woord/zin in je reactie gezet, je reactie is dus niet geplaats." Maar als ik Hoi, ik ben piet neer zet dat plaatst ie gewoon, hoe moet ik dit oplossen?
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$telkarakters[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$telkarakters[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]25[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je reactie is te groot![/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];
    }[/COLOR]
?>


Bij probleem 2 kan je beter werken met in_array volgens mij wink
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Sanderc schreef:
[COLOR= #0000BB]<?php
$telkarakters[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$telkarakters[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]25[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je reactie is te groot![/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];
    }[/COLOR]
?>
Bij probleem 2 kan je beter werken met in_array volgens mij wink
Sander, ik had die functie net gevonden biggrin nu probleem 2 nog.

Hoe kan een array maken die woorden uit de database ophaald?
0
Berichten
3.112
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uitvoer[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700])){[/COLOR]
[COLOR= #0000BB]$array[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #0000BB]$uitvoer[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]veld[/COLOR][COLOR= #007700]];
}[/COLOR]
?>


Nu is $array een array met alle waardes.
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Oke, ik heb zelf dit:

$bericht = strtolower($_POST[reactie]);
                                                        $woorduitdatabase = mysql_query("SELECT * FROM woordfilter");
                                                        $feth = mysql_fetch_array($woorduitdatabase);
                                                        if(in_array($bericht, $feth)) {
                                                            echo Je hebt een verboden woord/zin in je reactie gezet, je reactie is dus niet geplaatst. <br />;
                                                            $mail = false;
                                                        }


en dit werkt ook, alleen als ik in de woordfilter bijv. test zet en ik zet in reactie hey test werkt het niet.

Even die van hier boven uitproberen

toevoeging op 30 juli 2012, 13:02:17:

$select = mysql_query("SELECT * FROM woordfilter");
                                                        while($uitvoer = mysql_fetch_assoc($select)){
                                                            $array[] = $uitvoer[woord];
                                                            if(in_array($_POST[reactie] ,$array)) {
                                                                
                                                            }
                                                        }


werkt nietsadley
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zoiets? Geen idee of dit werkt yummie
[COLOR= #0000BB]<?php

$verbodenwoord[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM woordfilter"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uitvoer[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700])){[/COLOR]
        [COLOR= #0000BB]$woorden[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #0000BB]$uitvoer[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]veld[/COLOR][COLOR= #007700]];
}[/COLOR]

[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$woorden[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$woord[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$woord[/COLOR][COLOR= #007700]){[/COLOR]
                [COLOR= #0000BB]$verbodenwoord[/COLOR] [COLOR= #007700]=[/COLOR] true[COLOR= #007700];
        }
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$verbodenwoord[/COLOR] [COLOR= #007700]==[/COLOR] true[COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt een verboden woord/zin in je reactie gezet, je reactie is dus niet geplaatst. <br />[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];
}[/COLOR]

?>
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Oke, even netjes samengevat, ik heb alleen probleem 2 nog. Deze script heb ik nu:

[COLOR= #0000BB]<?php[/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]
                                                        
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]])) {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt geen reactie ingevuld <br />[/COLOR][COLOR= #007700];[/COLOR]
                [COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];
                }[/COLOR]
            [COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]]) -[/COLOR] [COLOR= #0000BB]25[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]]) >[/COLOR] [COLOR= #0000BB]25[/COLOR][COLOR= #007700]) {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je reactie is te groot, je reactie mag maximaal 25 tekens bevatten, die van jou had er [/COLOR][COLOR= #007700].[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]]) .[/COLOR][COLOR= #DD0000]. Dat zijn er dus [/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$count[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #DD0000] te veel![/COLOR][COLOR= #007700];[/COLOR]
            [COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];
                }[/COLOR]
            [COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strtolower"]strtolower[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]]);[/COLOR]
            [COLOR= #0000BB]$woorduitdatabase[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM wordfilter"[/COLOR][COLOR= #007700]);[/COLOR]
            [COLOR= #0000BB]$feth[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$woorduitdatabase[/COLOR][COLOR= #007700]);[/COLOR]
                                                        
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$feth[/COLOR][COLOR= #007700])) {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt een verboden woord/zin in je reactie gezet, je reactie is dus niet geplaatst. <br />[/COLOR][COLOR= #007700];[/COLOR]
            [COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];
            }[/COLOR]
                                                        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]!==[/COLOR] false[COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Jou reactie is succesvol geplaats![/COLOR][COLOR= #007700];
                                                            
    }
}[/COLOR]
                                                
?>
Thommity schreef:
Zoiets? Geen idee of dit werkt yummie
[COLOR= #0000BB]<?php

$verbodenwoord[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM woordfilter"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uitvoer[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700])){[/COLOR]
        [COLOR= #0000BB]$woorden[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #0000BB]$uitvoer[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]veld[/COLOR][COLOR= #007700]];
}[/COLOR]

[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$woorden[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$woord[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strpos"]strpos[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]reactie[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$woord[/COLOR][COLOR= #007700]){[/COLOR]
                [COLOR= #0000BB]$verbodenwoord[/COLOR] [COLOR= #007700]=[/COLOR] true[COLOR= #007700];
        }
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$verbodenwoord[/COLOR] [COLOR= #007700]==[/COLOR] true[COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Je hebt een verboden woord/zin in je reactie gezet, je reactie is dus niet geplaatst. <br />[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];
}[/COLOR]

?>


Als de reactie nu: hey test is werkt het. Zet ik er test in, werkt het niet, zet ik er 2x test in werkt het ook niet?
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
heb je $uitvoer[veld]; veranderd?
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Jep.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Een tip: Empty() is een waardeloze functie in mijn ogen. Je kan hier weliswaar wel mee controleren of een string is ingevuld, maar deze retourneert ook false bij waardes als NULL, FALSE, 0...
Niet handig als je een aantal verwacht, zoals bijv. 0.

Een betere optie is gewoon een vergelijking met een lege string, waar je trim() over heen haalt

if(trim($string)==) {


En dan nog iets: het is Jouw reactie, met een w erbij.
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Aarclay schreef:
Een tip: Empty() is een waardeloze functie in mijn ogen. Je kan hier weliswaar wel mee controleren of een string is ingevuld, maar deze retourneert ook false bij waardes als NULL, FALSE, 0...
Niet handig als je een aantal verwacht, zoals bijv. 0.

Een betere optie is gewoon een vergelijking met een lege string, waar je trim() over heen haalt

if(trim($string)==) {
En dan nog iets: het is Jouw reactie, met een w erbij.

Oh, bedankt voor de tip!

Kan je ook nog helpen met probleem 2?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Niet om lullig te zijn, verboden woorden zijn eenvoudig te omzeilen.... al is met met spaties, interpuncties of verbasteringen.
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Aarclay schreef:
Niet om lullig te zijn, verboden woorden zijn eenvoudig te omzeilen.... al is met met spaties, interpuncties of verbasteringen.
Spaties = gewoon met trim() het bericht aanelkaar zetten en dan zoeken of het verboden woord erinstaat
Hoofdletters = strtlolwer();
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
En als iemand k.u.t. invult? of kudt op zijn GeenStijls?

Als ze er achter komen verzinnen ze toch wel wat nieuws... Daarom heeft woorden verbieden in mijn ogen weinig nut.
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Aarclay schreef:
En als iemand k.u.t. invult? of kudt op zijn GeenStijls?

Als ze er achter komen verzinnen ze toch wel wat nieuws... Daarom heeft woorden verbieden in mijn ogen weinig nut.
Dan kan ik die manieren weer in de woordfilter zettenbiggrin
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