Gratis berichtenbalk

Gestart doorJeffreyy16 reacties60 weergaven

17 berichten · pagina 1 van 2

Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik ben ook weer een beetje aan het oefenen met PHP.
Dit is mijn eerste script met PHP + SQL.

<marquee style="font-family:verdana; font-size: 11px;" OnMouseOver="this.stop()" OnMouseOut="this.start()">
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//-----------------[MySQL Informatie][/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]root[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//database user[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//database password[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]host[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]localhost[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//database host[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]db[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]berichtenbalk[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//database naam[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]host[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]db[/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] [COLOR= #FF8000]// Verbinding maken met database[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]db[/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] [COLOR= #FF8000]// Database selecteren
//-----------------[Berichten weergeven][/COLOR]
[COLOR= #0000BB]$getinfo[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM berichten LIMIT 15"[/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]
[COLOR= #0000BB]$get[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM berichten"[/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]
[COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$getinfo[/COLOR][COLOR= #007700])) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]admin[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]1[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #DD0000]0[/COLOR][COLOR= #007700]) {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<i>Er zijn nog geen berichten geplaatst.</i>[/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]".: <strong style=color:red;>"[/COLOR] [COLOR= #007700].[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]"</strong>: "[/COLOR] [COLOR= #007700].[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" :. "[/COLOR][COLOR= #007700];
        }
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #DD0000]0[/COLOR][COLOR= #007700]) {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<i>Er zijn nog geen berichten geplaatst.</i>[/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]".: <strong>"[/COLOR] [COLOR= #007700].[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]"</strong>: "[/COLOR] [COLOR= #007700].[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" :. "[/COLOR][COLOR= #007700];
        }
    }
}[/COLOR] 
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<span style="font-weight:bold;color:gray;"><a href="?toevoegen">[Bericht toevoegen?]</a></span></marquee><hr>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]//-----------------[Toevoegen script][/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][COLOR= #DD0000]toevoegen[/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][COLOR= #DD0000]x[/COLOR][COLOR= #007700]])) {[/COLOR]
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO berichten (naam,bericht,ip) VALUES ("[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/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/echo"]echo[/URL] [COLOR= #DD0000]Toegevoegd![/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]<form method="post" action=""><input type="text" name="naam" value="Naam.."><br><textarea name="bericht" style="width: 350px; height:100px;">Bericht..</textarea><br><input type="submit" name="x" value="Toevoegen"></form>[/COLOR][COLOR= #007700];
    }[/COLOR]
[COLOR= #FF8000]//-----------------[Bron weergeven][/COLOR]
[COLOR= #007700]}[/COLOR] [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]source[/COLOR][COLOR= #007700]])) {[/COLOR]
    [URL="http://www.php.net/highlight_file"]highlight_file[/URL][COLOR= #007700]([/COLOR]__FILE__[COLOR= #007700]);
}[/COLOR]
?>
0
Krm

Lid

Berichten
6.235
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Moeten we beoordelen of is het om te delen
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Beoordelen graag,
Feedback is altijd welkom.

En je mag hem gebruiken zolang je hem niet doorverkoopt, doorgeeft, of publiceert onder je eigen naam.
0
Berichten
418
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
feedback? Nouja het is slordig.
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
En wat is er slordig aan dan?
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ietsjes meer enters gebruiken.

<marquee style="font-family:verdana; font-size: 11px;" OnMouseOver="this.stop()" OnMouseOut="this.start()">
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]//-----------------[MySQL Informatie][/COLOR]

[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]root[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//database user[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//database password[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]host[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]localhost[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//database host[/COLOR]
[COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]db[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]berichtenbalk[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//database naam[/COLOR]

[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]host[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]db[/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] [COLOR= #FF8000]// Verbinding maken met database[/COLOR]

[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]db[/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] [COLOR= #FF8000]// Database selecteren

//-----------------[Berichten weergeven][/COLOR]

[COLOR= #0000BB]$getinfo[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM berichten LIMIT 15"[/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]
[COLOR= #0000BB]$get[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM berichten"[/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]
[COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$getinfo[/COLOR][COLOR= #007700])) {[/COLOR]

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

        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]0[/COLOR][COLOR= #007700]) {[/COLOR]

            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<i>Er zijn nog geen berichten geplaatst.</i>[/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]".: <strong style=color:red;>"[/COLOR] [COLOR= #007700].[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]"</strong>: "[/COLOR] [COLOR= #007700].[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" :. "[/COLOR][COLOR= #007700];

        }

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

        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]0[/COLOR][COLOR= #007700]) {[/COLOR]

            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<i>Er zijn nog geen berichten geplaatst.</i>[/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]".: <strong>"[/COLOR] [COLOR= #007700].[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]"</strong>: "[/COLOR] [COLOR= #007700].[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$info[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" :. "[/COLOR][COLOR= #007700];

        }

    }

}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<span style="font-weight:bold;color:gray;"><a href="?toevoegen">[Bericht toevoegen?]</a></span></marquee><hr>[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #FF8000]//-----------------[Toevoegen script][/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][COLOR= #DD0000]toevoegen[/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][COLOR= #DD0000]x[/COLOR][COLOR= #007700]])) {[/COLOR]

        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO berichten (naam,bericht,ip) VALUES ("[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]bericht[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/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/echo"]echo[/URL] [COLOR= #DD0000]Toegevoegd![/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]<form method="post" action=""><input type="text" name="naam" value="Naam.."><br><textarea name="bericht" style="width: 350px; height:100px;">Bericht..</textarea><br><input type="submit" name="x" value="Toevoegen"></form>[/COLOR][COLOR= #007700];

    }[/COLOR]

[COLOR= #FF8000]//-----------------[Bron weergeven][/COLOR]

[COLOR= #007700]}[/COLOR] [URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]source[/COLOR][COLOR= #007700]])) {[/COLOR]

    [URL="http://www.php.net/highlight_file"]highlight_file[/URL][COLOR= #007700]([/COLOR]__FILE__[COLOR= #007700]);

}[/COLOR]
?>
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt voor de tip!
0
Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

7/10, Je kan het beste een bericht toevoegen op een andere pagina/pop-up doen, en voorderest wel netjes! (Allen inderdaad nog die enters)
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zou ook kunnen, maar dan kan ik net zo goed meteen een layout dr omheen bouwen.
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je kan ook beter zo je else schrijven:

}
else
{


Dit vind ik persoonlijk netter.
0
Berichten
2.837
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Indd
en ik zou ook niet zoveel enter gebruiken ik zou alleen dit doen:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]()
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]hello[/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]hello world[/COLOR][COLOR= #007700];
}[/COLOR]
?>
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hmm, ik heb daar niet zo veel problemen mee hoor, gewoon een beetje goed kijken en het moet lukken.
0
Berichten
1.544
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik gebruik zelf ook gewoon }else{
Maar wat ik misschien nog wel aanraad is om "Tab" te gebruiken IPV een aantal keer die spatie.
0
Jeffreyy

Lid · Topicstarter

Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Doe ik ook hoor?

Alleen misschien dat Notepad++ ze omzet ofzo?
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
if($info[admin] == 1) {

kun je beter schrijven als

if($info[admin] == 1) {

om getallen hoeven eenmaal geen tekens, het is zelfs sneller zonder tekens.

if($aantal <= 0) {

hoe kunnen het aantal berichten minder dan 0 zijn?

$get = mysql_query("SELECT * FROM berichten") or die(mysql_error());
$aantal = mysql_num_rows($get);

kun je beter schrijven:

$get = mysql_query("SELECT COUNT(1) AS aantal FROM berichten") or die(mysql_error());
$fetch = mysql_fetch_assoc($get);
$aantal = $fetch[aantal];

wanneer je via post iets in de database zet, moet je deze gegevens beveiligen via: "mysql_real_escape_string", zodat sql injection niet meer mogelijk is.

query komt er dan als volgt uit te zien:

mysql_query("
                INSERT INTO 
                    berichten 
                (
                    naam,
                    bericht,
                    ip
                ) 
                VALUES 
                (
                    ".mysql_real_escape_string($_POST[naam]).",
                    ".mysql_real_escape_string($_POST[bericht]).",
                    ".$_SERVER[REMOTE_ADDR]."
                )
            ") or die(mysql_error());


while($info = mysql_fetch_array($getinfo)) {

je kunt beter mysql_fetch_assoc gebruiken dit werkt namelijk sneller

while($info = mysql_fetch_assoc($getinfo)) {

Hoop dat je er iets mee kunt.

Groetjes,
Marijn
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