Hallo, undzwar habe ich ein Problem, das PHP bei folgenden Skript nicht die Umlaute per htmlentities in die in HTML bestimmten Zeichencodes umändert.
Code:
Code:
PHP-Code:
<html>
<head>
<link href="../../css/craftbootstrap.css" type="text/css" rel="stylesheet"></link>
<body>
<?
// einlesen von Post´s
$strTitel=htmlentities($_POST['strTitel']);
$strNews=preg_replace('#<br />#','' , $_POST['strNews']);
$strNews=nl2br($strNews);
$strNews=htmlentities($strNews);
$strDate=htmlentities($_POST['strDate']);
$strTime=htmlentities($_POST['strTime']);
$strAuthor=htmlentities($_POST['strAuthor']);
// error auf 0
$intError=0; ?>
<fieldset>
<legend>Neue Nachricht überprüfen</legend>
<form name="input1" id="input1" method="post" action="<? echo($PHP_SELF) ?>">
<label for="strTitel" class="left">Titel:</label>
<? if ($strTitel!="") {
echo $strTitel;
?><input name="strTitel" type="hidden" value="<? echo $strTitel; ?>" /><?
}
else {
$intError=1;
?><input type="text" name="strTitel" align="right" style="background: #ff0000;" /><?
} ?>
<br />
<label for="strNews" class="left">Nachricht:</label>
<? if ($strNews!="") {
echo "<br /><br />".$strNews;
?><input name="strNews" type="hidden" value="<? echo $strNews; ?>" /><?
}
else {
$intError=1;
?><textarea name="strNews" cols="30" rows="10" align="right" style="background: #ff0000;"></textarea><?
} ?>
<br />
<label for="strDate" class="left">Startdatum:</label>
<? if ($strDate=="") {
$strDate=date('d.m.Y');
$intError=1
?><input name="strDate" type="text" size="10" maxlength="10" align="right" value="<? echo $strDate; ?>" style="background: #ff0000;" /><?
}
else {
$arrDatePart=explode(".", $strDate);
if (checkdate($arrDatePart[1], $arrDatePart[0], $arrDatePart[2])) {
echo ($strDate);
?><input name="strDate" type="hidden" value="<? echo $strDate; ?>" /><?
}
else {
?><input name="strDate" type="text" size="10" maxlength="10" align="right" value="<? echo date('d.m.Y'); ?>" style="background: #ff0000;" /><?
$intError=1;
}
} ?>
(MM.DD.YYYY)<br>
<label for="strTime" class="left">Startzeit:</label>
<?
if ($strTime=="") {
$strTime=date('H:i');
$intError=1
?><input name="strTime" type="text" size="10" maxlength="10" align="right" value="<? echo $strTime; ?>" style="background: #ff0000;" /><?
}
else {
$arrTimePart=explode(":", $strTime);
if (($arrTimePart[0]<=23) AND ($arrTimePart[0]>=0) AND ($arrTimePart[1]>=0) AND ($arrTimePart[1]<=59)) {
echo $strTime;
?><input name="strTime" type="hidden" value="<? echo $strTime; ?>" /><?
}
else {
?><input name="strTime" type="text" size="10" maxlength="10" align="right" value="<? echo date('H:i'); ?>" style="background: #ff0000;" /><?
}
} ?>
(HH:MM)<br>
<label for="strAuthor" class="left">Autor:</label>
<?
if ($strAuthor!="") {
echo $strAuthor;
?><input name="strAuthor" type="hidden" value="<? echo $strAuthor; ?>" /><?
}
else {
$intError=1;
?><input type="text" name="strAuthor" align="right" style="background: #ff0000;" /><?
}
?>
<br /><br />
<label for="" class="left"></label>
<? if ($intError==1) { ?>
<input name="intStep" type="hidden" value="1" />
<? }
else { ?>
<input name="intStep" type="hidden" value="2" />
<? } ?>
<input name="strAction" type="hidden" value="new" />
<? if ($intError==1) { ?>
<input type="submit" name="Submit" value="Berichtigen" class="submit" />
<? }
else { ?>
<input type="submit" name="Submit" value="Speichern" class="submit" />
<? } ?>
</form>
</fieldset>
</body>
</html>
Kommentar