[PHP&SQL] Gastenboek probleem (beloning 0..7 punt)

Gestart doorParadox18 reacties139 weergaven

19 berichten · pagina 1 van 2

Paradox

Lid · Topicstarter

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

Ik heb een probleem, ik zoek een oplossing om te zorgen dat mensen die in het gastenboek schrijven de naam admin niet kunnen gebruiken. Dus als iemand als naam invult: Admin dan moet de code dit als fout zien en er guest van maken.

Mijn code is nu:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR] crdeoxqg_oaf[COLOR= #007700],[/COLOR]WACHTWOORD[COLOR= #007700]);[/COLOR]     [COLOR= #FF8000]// zelf in te vullen[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR] crdeoxqg_oaf[COLOR= #007700]);[/COLOR]     [COLOR= #FF8000]// zelf in te vullen [/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][COLOR= #DD0000]door[/COLOR][COLOR= #007700]])[/COLOR] and [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]])[/COLOR] and [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]door[/COLOR][COLOR= #007700]]!=[/COLOR][COLOR= #DD0000]Uw naam.[/COLOR][COLOR= #007700]) {[/COLOR]
    [COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]];[/COLOR]
    [COLOR= #0000BB]$door[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]door[/COLOR][COLOR= #007700]];[/COLOR]
    [COLOR= #0000BB]$datum[/COLOR] [COLOR= #007700]=[/COLOR]  [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"d-m-Y"[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$tijd[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"H:i:s"[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]());[/COLOR]
    
    [COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"<br>"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700]);[/COLOR]
    
    [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"INSERT INTO gastenboek(bericht, door, datum, tijd) VALUES ("[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$door[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$datum[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$tijd[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700];[/COLOR] 
      [COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]=[/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/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]


Dit is van het posten.
$door is de naam zeg maar.

De gene met de oplossing krijgt een beloning van 0.7 punt! (alleen voor de 1e)

Edit had me wachtwoord er nog instaan. daar staat nu WACHTWOORD

Edit door Ruben: ff php van gemaakt, is wat overzichtelijker
0
Berichten
7
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
succes smile
0
Berichten
2.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?[/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][COLOR= #DD0000]door[/COLOR][COLOR= #007700]])[/COLOR] and [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]])[/COLOR] and [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]door[/COLOR][COLOR= #007700]]!=[/COLOR][COLOR= #DD0000]Uw naam.[/COLOR][COLOR= #007700]) {[/COLOR]


Vervangen door:

[COLOR= #0000BB]<?[/COLOR]php
[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][COLOR= #DD0000]door[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]) &&[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]door[/COLOR][COLOR= #007700]]!=[/COLOR][COLOR= #DD0000]Uw naam.[/COLOR] [COLOR= #007700]&&[/COLOR] [URL="http://www.php.net/strtolower"]strtolower[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]door[/COLOR][COLOR= #007700]]) !=[/COLOR] [COLOR= #DD0000]admin[/COLOR][COLOR= #007700]) {[/COLOR] 

# Ff deze line zodat je kan scrollen [COLOR= #007700]:[/COLOR][COLOR= #007700])[/COLOR]


Is btw niet het best gescripte systeem ooit
0
Paradox

Lid · Topicstarter

Berichten
193
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee is niet best gescript. Heb ik zelf gemaakt en niet echt goed xD
Moet je de punten hebben? xD

In ieder geval bedankt!
0
Berichten
2.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nah, zit wel goed emo
0
Paradox

Lid · Topicstarter

Berichten
193
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Btw, nu heb ik nogsteeds probleem. Ik wil dat er een andere naam van gemaakt wordt. En dat het dus ook werkt met Webmaster en SiteAdmin enz

Is dat ook mogelijk?

Want dan wil ik dat als je bijvoorbeeld intypt : --Admin-- dat ie er dan wel gewoon admin van maakt.

Alvast Bedankt

Edit: moet iets zijn met eregi_replace maar ik krijg het er niet werkend in.
0
Berichten
2.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nah, dan moet je alles typen in een array

[COLOR= #0000BB]<?php
$namen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]admin[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]blaat[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]admin-[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]// Alles lowercase[/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][COLOR= #DD0000]door[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]) &&[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]door[/COLOR][COLOR= #007700]]!=[/COLOR][COLOR= #DD0000]Uw naam.[/COLOR] [COLOR= #007700]&& ![/COLOR][URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR]strotolower[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]door[/COLOR][COLOR= #007700]]),[/COLOR] [COLOR= #0000BB]$namen[/COLOR][COLOR= #007700])) {[/COLOR]
0
Paradox

Lid · Topicstarter

Berichten
193
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoe krijg je dan die eregi_replace in een aray? of ben ik nou gek ? confused
0
Berichten
2.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
...? Waarom wil je een replace doen? emo
Edit: Nah, dat werkt niet, is onmogelijk

Je kan doen (ik kan ff niet op de functienam komen) if(eregi(admin, $_POST[door]))
0
Paradox

Lid · Topicstarter

Berichten
193
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Om te zorgen dat het wel mogelijk is admin als naam op te geven. maar alleen wanneer je bijv +admin+ typt en niet als je gwn admin typt. snapie ?
0
Berichten
7
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
dan is +admin+ soort van wachtwoord voor de naam admin smile
0
Paradox

Lid · Topicstarter

Berichten
193
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat let jij goed op (op msn!)
0
Berichten
7
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
hehe santabaard
0
Berichten
2.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
if(eregi(admin, strtolower($_POST[door]))

Maar eregi is wel zwaar denk ik
0
Paradox

Lid · Topicstarter

Berichten
193
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb oplossing ;p
Improvisatie maar het werkt ;p
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