php gastenboek
Waar en hoe moet ik dit aanpassen in het volgende script?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?
$amount=15;
if ($_GET['action']=='write') {
header('location: gb.php?action=read&start=0');
$file=fopen('gastenboek.txt','a');
$message=str_replace("\r",'',$message);
$message=str_replace("\n",'{{',$_GET['message']);
fwrite($file,$_GET['name'].'|||'.$_GET['email'].'|||'.date('d-m-Y').'|||'.$_GET['url'].'|||'.$message."\n");
fclose($file);
}
$start=(isset($_GET['start'])?$_GET['start']:0);
$gastenboek=Array();
$gastenboek=file('gastenboek.txt');
?>
$amount=15;
if ($_GET['action']=='write') {
header('location: gb.php?action=read&start=0');
$file=fopen('gastenboek.txt','a');
$message=str_replace("\r",'',$message);
$message=str_replace("\n",'{{',$_GET['message']);
fwrite($file,$_GET['name'].'|||'.$_GET['email'].'|||'.date('d-m-Y').'|||'.$_GET['url'].'|||'.$message."\n");
fclose($file);
}
$start=(isset($_GET['start'])?$_GET['start']:0);
$gastenboek=Array();
$gastenboek=file('gastenboek.txt');
?>
<SCRIPT language="JavaScript">
function validate(form) {
if (form.name.value=="") {
alert("Vul je naam in");
return false;
} else if (form.message.value=="") {
alert("Vul je bericht in");
return false;
}
}
</SCRIPT>
<P>
<TABLE width="100%" cellspacing="0" cellpadding="0" >
<TR>
<TD><b>Gastenboek</b><br></TD>
</TR>
</TABLE>
<TABLE width="100%" cellspacing="0" cellpadding="0">
<TR>
<TD class="side"> Berichten tot en met .
<HR> <TABLE width="100%" >
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?
$gastenboek=array_reverse($gastenboek);
for ($i=$start;$i<$start+$amount && $i<sizeof($gastenboek);$i++) {
list($name,$email,$date,$url,$message)=explode('|||',$gastenboek[$i]);
$message=str_replace('{{',"\n",$message);
echo '<TR><TD><B>'.($email!=""?'<A href="mailto:'.$email.'">'.$name.'</A>':$name).'</B></TD><TD align="right"><B>'.$date.'</B></TD></TR>'."\n";
echo ($url!=""?'<TR><TD colspan="2"><A href="'.$url.'" target="_blank">'.$url.'</A></TD></TR>':'')."\n";
echo '<TR><TD colspan="2"><SPAN>'.str_replace("\n",'<BR>',htmlspecialchars($message)).'</SPAN></TD></TR>'."\n";
echo '<TR><TD colspan="2"><HR></TD></TR>'."\n";
}
?>
$gastenboek=array_reverse($gastenboek);
for ($i=$start;$i<$start+$amount && $i<sizeof($gastenboek);$i++) {
list($name,$email,$date,$url,$message)=explode('|||',$gastenboek[$i]);
$message=str_replace('{{',"\n",$message);
echo '<TR><TD><B>'.($email!=""?'<A href="mailto:'.$email.'">'.$name.'</A>':$name).'</B></TD><TD align="right"><B>'.$date.'</B></TD></TR>'."\n";
echo ($url!=""?'<TR><TD colspan="2"><A href="'.$url.'" target="_blank">'.$url.'</A></TD></TR>':'')."\n";
echo '<TR><TD colspan="2"><SPAN>'.str_replace("\n",'<BR>',htmlspecialchars($message)).'</SPAN></TD></TR>'."\n";
echo '<TR><TD colspan="2"><HR></TD></TR>'."\n";
}
?>
</TABLE>
<CENTER>
Code (php)
</TR>
</TABLE>
<P>
<TABLE width="100%" cellspacing="0" cellpadding="0" >
<TR>
<TD class="side">Nieuw bericht</TD>
</TR>
</TABLE>
<TABLE width="100%" cellspacing="0" cellpadding="0" >
<TR>
<TD class="side"> <FORM action="gb.php" method="GET" onSubmit="return validate(this);">
<INPUT type="hidden" name="action" value="write">
<TABLE class="side">
<TR>
<TD>Naam:</TD>
<TD><INPUT type="text" name="name" size="30"></TD>
</TR>
<TR>
<TD>E-Mail:</TD>
<TD><INPUT type="text" name="email" size="30">
(optioneel)</TD>
</TR>
<TR>
<TD>Homepage:</TD>
<TD><INPUT name="url" type="text" value="http://" size="30">
(optioneel)</TD>
</TR>
<TR>
<TD>Bericht:</TD>
<TD><TEXTAREA name="message" cols="50" rows="5"></TEXTAREA></TD>
</TR>
</TABLE>
<INPUT type="submit" value="Verstuur">
</FORM></TD>
</TR>
</TABLE><p align="left">
</td>
</tr>
</table>
en dit dan in de for loop...
En dan moet je de echo even verandere ;)