editwhat.php
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font size="4"><b>News bearbeiten</b></font></td>
</tr>
<tr height="15">
<td></td>
</tr>
<?
include ("config.php");
include ("switch.php");
$q_select="SELECT * FROM news ORDER BY datum DESC, zeit DESC LIMIT $start, $datensaetze_pro_seite";
$r_select=mysql_query($q_select);
while ($arrData=mysql_fetch_array($r_select, MYSQL_ASSOC))
{
?>
<form action="<? echo $PHP_SELF; ?>" method="post" name="choise<? echo $arrData[id]; ?>" id="choise<? echo $arrData[id]; ?>">
<input type="hidden" value="1" name="intStep">
<input type="hidden" value="edit" name="strAction">
<input type="hidden" value="<? echo $arrData[id]; ?>" name="intItem">
<tr>
<td width="172" for="strAction"><b>ID [<? echo $arrData[id]; ?>]:</b></td>
<td width="72"><b>Titel:</b></td>
<td width="272"><? echo $arrData[titel]; ?></td>
<td><input type="submit" value="Bearbeiten" name="Submit"> <input type="button" value="Zurück" onClick="history.back()" name="Submit2"></td>
</tr>
<tr height="15">
<td></td>
</tr>
</form>
<?
}
echo "<tr height=\"15\">";
echo "<td></td>";
echo "</tr>";
echo "<td width=\"172\" id=\"site\">";
echo $link_string;
echo "</td>";
echo "<td width=\"172\">";
echo "<span class=\"site\"><b>Seite ".$go." von ".$seiten."</b></span>";
echo "</td>";
echo "</tr>";
mysql_close($connect);
?>
</table>
editform.php
<?
include ("config.php");
$intId=$_POST['intItem'];
$q_select="SELECT * FROM news WHERE id=$intId";
$r_select=mysql_query($q_select);
while ($arrData=mysql_fetch_array($r_select, MYSQL_ASSOC))
{
$intDatePart=explode("-", $arrData[datum]);
$strDatum=$intDatePart[2].".".$intDatePart[1].".".$intDatePart[0]." ".$strAusgabe[zeit];
$strNews=preg_replace("=<br(>|([\s/][^>]*)>)\r?\n?=i", "\n", $arrData[inhalt]);
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font size="4"><b>News bearbeiten</b></font></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<form action="<? echo($PHP_SELF) ?>" method="post" name="input1" id="input1">
<input type="hidden" value="2" name="intStep">
<input type="hidden" value="edit" name="strAction">
<input type="hidden" value="<? echo $arrData[id]; ?>" name="intItem">
<td width="172" for="strTitel"><b>Titel:</b></td>
<td><input type="text" size="26" value="<? echo $arrData[titel]; ?>" name="strTitel"></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strAutor"><b>Autor:</b></td>
<td><input type="text" size="26" value="<? echo $arrData[autor]; ?>" name="strAutor"></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strEmail"><b>E-Mail:</b></td>
<td><input type="text" size="26" value="<? echo $arrData[email]; ?>" name="strEmail"></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strDate"><b>Datum:</b></td>
<td><input type="text" value="<? echo $strDatum; ?>" size="10" maxlength="10" name="strDate"></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strTime"><b>Zeit:</b></td>
<td><input type="text" value="<? echo $arrData[zeit]; ?>" size="10" maxlength="8" name="strTime"></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strKommentar"><b>URL (Kommentar):</b></td>
<td><input type="text" size="26" value="<? echo $arrData[kommentar]; ?>" name="strKommentar"></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strAvatar"><b>URL (Avatar):</b></td>
<td><input type="text" size="26" value="<? echo $arrData[avatar]; ?>" name="strAvatar"></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" valign="top" for="strNews"><b>Inhalt:</b></td>
<td><textarea cols="100" rows="10" name="strNews"><? echo $strNews; ?></textarea></td>
</tr>
<tr height="15">
<td for=""></td>
</tr>
<tr>
<td width="172" height="25"><input type="submit" value="Bearbeiten" name="Submit"> <input type="reset" value="Abbrechen" name="Submit2"></td>
</tr>
</table>
</form>
<?
}
mysql_close($connect);
?>
editerror.php
<?
$strTitel=htmlentities($_POST['strTitel']);
$strAutor=htmlentities($_POST['strAutor']);
$strEmail=htmlentities($_POST['strEmail']);
$strDate=htmlentities($_POST['strDate']);
$strTime=htmlentities($_POST['strTime']);
$strKommentar=htmlentities($_POST['strKommentar']);
$strAvatar=htmlentities($_POST['strAvatar']);
$strNews=preg_replace('#<br />#','' , $_POST['strNews']);
$strNews=nl2br(htmlentities($strNews));
$intItem=$_POST['intItem'];
$intError=0;
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font size="4"><b>News überprüfen</b></font></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<form action="<? echo($PHP_SELF) ?>" method="post" name="input1" id="input1">
<td width="172" for="strTitel"><b>Titel:</b></td>
<?
if ($strTitel!="")
{
echo "<td>".$strTitel."</td>";
?>
<td><input type="hidden" value="<? echo $strTitel; ?>" name="strTitel"></td>
<?
}
else
{
$intError=1;
?>
<td><input type="text" size="26" style="background-color:#FFE6E6;" name="strTitel"></td>
<?
}
?>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strAutor"><b>Autor:</b></td>
<?
if ($strAutor!="")
{
echo "<td>".$strAutor."</td>";
?>
<td><input type="hidden" value="<? echo $strAutor; ?>" name="strAutor"></td>
<?
}
else
{
$intError=1;
?>
<td><input type="text" size="26" style="background-color:#FFE6E6;" name="strAutor"></td>
<?
}
?>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strEmail"><b>E-Mail:</b></td>
<?
if ($strEmail!="")
{
echo "<td>".$strEmail."</td>";
?>
<td><input type="hidden" value="<? echo $strEmail; ?>" name="strEmail"></td>
<?
}
else
{
$intError=1;
?>
<td><input type="text" size="26" style="background-color:#FFE6E6;" name="strEmail"></td>
<?
}
?>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strDate"><b>Datum:</b></td>
<?
if ($strDate=="")
{
$strDate=date('d.m.Y');
$intError=1
?>
<td><input type="text" value="<? echo $strDate; ?>" size="10" maxlength="10" style="background-color:#FFE6E6;" name="strDate"></td>
<?
}
else
{
$arrDatePart=explode(".", $strDate);
if (checkdate($arrDatePart[1], $arrDatePart[0], $arrDatePart[2]))
{
echo "<td>".($strDate)."</td>";
?>
<td><input type="hidden" value="<? echo $strDate; ?>" name="strDate"></td>
<?
}
else
{
?>
<td><input type="text" value="<? echo date('d.m.Y'); ?>" size="10" maxlength="10" style="background-color:#FFE6E6;" name="strDate"></td>
<?
$intError=1;
}
}
?>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strTime"><b>Zeit:</b></td>
<?
if ($strTime=="")
{
$strTime=date('H:i:s');
$intError=1
?>
<td><input type="text" value="<? echo $strTime; ?>" size="10" maxlength="10" style="background-color:#FFE6E6;" name="strTime"></td>
<?
}
else
{
$arrTimePart=explode(":", $strTime);
if (($arrTimePart[0]<=23) AND ($arrTimePart[0]>=0) AND ($arrTimePart[1]>=0) AND ($arrTimePart[1]<=59))
{
echo "<td>".$strTime."</td>";
?>
<td><input type="hidden" value="<? echo $strTime; ?>" name="strTime"></td>
<?
}
else
{
?>
<td><input type="text" value="<? echo date('H:i:s'); ?>" size="10" maxlength="10" style="background-color:#FFE6E6;" name="strTime"></td>
<?
}
}
?>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" for="strKommentar"><b>URL (Kommentar):</b></td>
<?
if ($strKommentar!="")
{
echo "<td>".$strKommentar."</td>";
?>
<td><input type="hidden" value="<? echo $strKommentar; ?>" name="strKommentar"></td>
<?
}
else
{
$intError=1;
?>
<td><input type="text" size="26" style="background-color:#FFE6E6;" name="strKommentar"></td>
<?
}
?>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" valign="top" for="strAvatar"><b>URL (Avatar):</b></td>
<?
if ($strAvatar!="")
{
echo "<td><img src=".$strAvatar." border=\"0\" width=\"100\" height=\"150\"></td>";
?>
<td><input type="hidden" value="<? echo $strAvatar; ?>" name="strAvatar"></td>
<?
}
else
{
$intError=1;
?>
<td><input type="text" size="26" style="background-color:#FFE6E6;" name="strAvatar"></td>
<?
}
?>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<td width="172" valign="top" for="strNews"><b>Inhalt:</b></td>
<?
if ($strNews!="")
{
echo "<td width=\"652\">".$strNews."</td>";
?>
<td><input type="hidden" value="<? echo $strNews; ?>" name="strNews"></td>
<?
}
else
{
$intError=1;
?>
<td><textarea cols="100" rows="10" style="background-color:#FFE6E6;" name="strNews"></textarea></td>
<?
}
?>
</tr>
<tr height="15">
<td for=""></td>
</tr>
<tr>
<input type="hidden" value="<? echo $intItem; ?>" name="intItem">
<?
if ($intError==1)
{
?>
<input type="hidden" value="2" name="intStep">
<?
}
else
{
?>
<input type="hidden" value="3" name="intStep">
<?
}
?>
<input type="hidden" value="edit" name="strAction">
<?
if ($intError==1)
{
?>
<td><input type="submit" value="Ändern" name="Submit"> <input type="button" value="Zurück" onClick="history.back()" name="Submit2"></td>
<?
}
else
{
?>
<td><input type="submit" value="Speichern" name="Submit"> <input type="button" value="Zurück" onClick="history.back()" name="Submit2"></td>
<?
}
?>
</tr>
</table>
</form>
editsave.php
<?
$strTitel=htmlentities($_POST['strTitel']);
$strAutor=htmlentities($_POST['strAutor']);
$strEmail=htmlentities($_POST['strEmail']);
$strDate=htmlentities($_POST['strDate']);
$strTime=htmlentities($_POST['strTime']);
$strKommentar=htmlentities($_POST['strKommentar']);
$strAvatar=htmlentities($_POST['strAvatar']);
$strNews=preg_replace('#<br />#','' , $_POST['strNews']);
$strNews=nl2br(htmlentities($strNews));
$intItem=$_POST['intItem'];
include ("config.php");
$strTime=$_POST['strTime'];
$intDatePart=explode(".", $_POST['strDate']);
$strMysqlDate="$intDatePart[2]-$intDatePart[1]-$intDatePart[0]";
$q_update="UPDATE news SET titel='$strTitel', autor='$strAutor', email='$strEmail', datum='$strMysqlDate', zeit='$strTime', kommentar='$strKommentar', avatar='$strAvatar', inhalt='$strNews' WHERE id='$intItem'";
$r_update=mysql_query($q_update);
if ($r_update==TRUE)
{
mysql_close($connect);
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font size="4"><b>News gespeichert</b></font></td>
</tr>
<tr height="15">
<td></td>
</tr>
<tr>
<form action="<? echo($PHP_SELF) ?>" method="post" name="choise1" id="choise1">
<input type="hidden" value="" name="strAction">
<td width="172" for="strAction"><b>Zurück zur Auswahl:</b></td>
<td><input type="submit" value="Zurück" name="Submit"></td>
</tr>
</table>
</form>
<?
}
else
{
echo "<b>Fehlermeldung:</b><br><br>".mysql_error();
die;
}
?>