Hoe doe ik dit : Geen plaintext e.d. op de berichtenbalk op de source van budget-scripts ?
Geen plaintext e.d. op de berichtenbalk
met htmlentities();
Kan je dit in me script bouwen ??
Als het goed is heb je ergens een query die het bericht in de berichtenbalk-tabel in je MySQL zet of niet?
In ieder geval ziet die query er ongeveer zo uit:
Dat moet worden:
Ik weet uiteraard niet precies wat de query is, maar het zal zoiets moeten worden.
In ieder geval ziet die query er ongeveer zo uit:
mysql_query("INSERT INTO berichtenbalk (naam, bericht) VALUES (".$_POST[naam].", ".$_POST[email]."") or die(mysql_error()); Dat moet worden:
mysql_query("INSERT INTO berichtenbalk (naam, bericht) VALUES (".htmlentities($_POST[naam]).", ".htmlentities($_POST[email])."") or die(mysql_error()); Ik weet uiteraard niet precies wat de query is, maar het zal zoiets moeten worden.
Ik heb dit :
if( isset($_POST["plaats"])) {
if($_POST["naam"] != "" && $_POST["bericht"] != "")
{
mysql_query("INSERT INTO berichten (id,bbid,afzender,bericht,ip) values (,".$_GET["id"].",".$_POST["naam"].",".$_POST["bericht"].",".$_SERVER[REMOTE_ADDR].")") or die(mysql_error());
echo"Bericht is succesvol geplaatst";
}else{
Trouwens er mogen ook geen urllink in kunnen..
if( isset($_POST["plaats"])) {
if($_POST["naam"] != "" && $_POST["bericht"] != "")
{
mysql_query("INSERT INTO berichten (id,bbid,afzender,bericht,ip) values (,".$_GET["id"].",".$_POST["naam"].",".$_POST["bericht"].",".$_SERVER[REMOTE_ADDR].")") or die(mysql_error());
echo"Bericht is succesvol geplaatst";
}else{
Trouwens er mogen ook geen urllink in kunnen..
[COLOR= #0000BB]<?php[/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]"plaats"[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][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]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO berichten (id,bbid,afzender,bericht,ip) values (,"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"id"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR]htmlentities[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]"Bericht is succesvol geplaatst"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR] Dan werkt ie denk ik

Ok,
ty!
Kan je het ook zo doen dat er in plaats van naam en text dikgedrukt is alleen de naam ??
ty!
Kan je het ook zo doen dat er in plaats van naam en text dikgedrukt is alleen de naam ??
Alleen de naam dikgedrukt bedoel je?
Dat zit sowieso in een ander deel van je script, bij waar de berichtenbalk wordt weergegeven zegmaar.
Dat zit sowieso in een ander deel van je script, bij waar de berichtenbalk wordt weergegeven zegmaar.
Schopje richting webwereld.
htmlentities() moet je pas doen als je het uit de database haalt he.
Anders kun je het nooit aanpassen zegmaar, omdat je niet weet wat je oorspronkelijke data was.
Anders kun je het nooit aanpassen zegmaar, omdat je niet weet wat je oorspronkelijke data was.Doe maar
htmlentities($string, ENT_QUOTES); Lennard schreef:Anders kun je het nooit aanpassen zegmaar, omdat je niet weet wat je oorspronkelijke data was.htmlentities() moet je pas doen als je het uit de database haalt he.
Het werkt wel...
Alleen nog html eruit..
Pascal schreef:Dat zit sowieso in een ander deel van je script, bij waar de berichtenbalk wordt weergegeven zegmaar.Alleen de naam dikgedrukt bedoel je?
Deze heb ik voor je
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bericht plaatsen</title>
<link href="opmaak.css" rel="stylesheet" type="text/css">
<script language=JavaScript>
function Smile(code) {
window.opener.document.form.bericht.value = code;
}
function Invoegen(veld,waarde,positie) {
veld = document.getElementById(veld);
if (document.selection) {
veld.focus();
Selectie = document.selection.createRange();
Selectie.text = waarde;
}
else if (veld.selectionStart || veld.selectionStart == 0) {
var begin = veld.value.substring(0,veld.selectionStart);
var einde = veld.value.substring(veld.selectionEnd,veld.value.length);;
veld.value = begin + waarde + einde;
veld.focus();
veld.selectionStart = veld.selectionEnd = (begin.length + waarde.length - positie);
}
else {
veld.value += waarde;
}
}
</script>
</head>
<body>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]db/config.php[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM berichtenbalk WHERE id="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$resultaat[/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]
[COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$resultaat[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Error #404"[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
[COLOR= #0000BB]<?Php
$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM ban WHERE ip = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" AND bbid="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/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]$res[/COLOR][COLOR= #007700]) >=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
{[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM ban WHERE ip="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" AND bbid="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/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/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$obj[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #0000BB]$reden[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$obj[/COLOR][COLOR= #007700]->[/COLOR]reden[COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je bent geband om de volgende reden :<BR> $reden<BR>Daarom kan je geen bericht plaatsen."[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
}
}[/COLOR]
?>
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM berichtenbalk WHERE id="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/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/while"]while[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$obj[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #0000BB]$reclame[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$obj[/COLOR][COLOR= #007700]->[/COLOR]reclame[COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$reclame[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$reclame[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<center><a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$siteurl[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" target="_blank" >Ook een gratis berichtenbalk ?</a></center>[/COLOR][COLOR= #007700];
}
}[/COLOR]
?>
[COLOR= #0000BB]<?php[/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]"plaats"[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][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]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO berichten (id,bbid,afzender,bericht,ip) values (,"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"id"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700].[/COLOR]htmlentities[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]"Bericht is succesvol geplaatst"[/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]"Je hebt iets niet ingevult"[/COLOR][COLOR= #007700];
}
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
<form method="post" id="form">
Naam :<BR>
<input type="text" name="naam"><BR>
Bericht :<BR>
<textarea cols="30" name="bericht" id="bericht">
</textarea><BR>
<a href=javascript:// onClick="Invoegen(bericht, :),0)"><img src="images/icon1.gif" border="0"></a> <a href=javascript:// onClick="Invoegen(bericht, :D,0)"><img src="images/icon2.gif" border="0"></a> <a href=javascript:// onClick="Invoegen(bericht, (h),0)"><img src="images/icon4.gif" border="0"></a><BR>
<input type="submit" name="plaats" value="Plaats bericht">
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}
}[/COLOR]
?>
<BR>
<BR>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$reclame[/COLOR][COLOR= #007700];[/COLOR]
?>
</body>
</html> Dat is enkel de plaats-bericht pagina? Daar moet je niet zoeken.
@htmlentities bij het uit database halen: ik doe altijd als ik het erin stop, tot nog toe nooit problemen mee gehad eigenlijk
?
@htmlentities bij het uit database halen: ik doe altijd als ik het erin stop, tot nog toe nooit problemen mee gehad eigenlijk
?Kan nogsteeds html..
Welke pagina dan ?
Welke pagina dan ?
Pascal schreef:@htmlentities bij het uit database halen: ik doe altijd als ik het erin stop, tot nog toe nooit problemen mee gehad eigenlijkDat is enkel de plaats-bericht pagina? Daar moet je niet zoeken.
?Komt nog wel dan.

Stel dat je een bewerk-optie wil maken, dan kan dat niet omdat je niet weet wat het oorspronkelijke bericht was. Opzich geen ramp omdat je het wel terug kunt redeneren (omgekeerde functie van htmlentities() gebruiken), maar t is "netter" en handiger om het achteraf te doen.
