Thanks. I hope you understand the few german wording. If not I will change it into english. The script works fine.
<?php
if($POST['sent']==1)
{
/
Kommentar:
Langschreibweise für die nachfolgende Kurzschreibform
$POST['name']=trim($POST['name']);
$POST['name']=strip_tags($POST['name']);
$POST['name']=htmlentities($POST['name']);
$POST['name']=str_replace('~','',$POST['name']);
/
$POST['name']=str_replace('~','',htmlentities(strip_tags(trim($POST['name']))));
$POST['betreff']=str_replace('~','',htmlentities(strip_tags(trim($POST['betreff']))));
$POST['message']=str_replace('~','',htmlentities(strip_tags(trim($POST['message']))));
if(!$POST['name']){$fehler="Bitte geben Sie einen Namen ein <br>";}
if(!$POST['betreff']){$fehler.="Bitte geben Sie den Betreff an<br>";}
if(!$POST['message']){$fehler.="Bitte geben Sie eine Nachrichtein<br>";}
if($fehler){$fehler='<h4><font color="red">'.$fehler.'</font></h4>';}
}
if($POST['name'] AND $POST['betreff'] AND $_POST['message'])
//Formular wurde ausgefüllt
{
$POST['message']=nl2br($POST['message']);
$POST['message']=str_replace(chr(10),'',$POST['message']);
$POST['message']=str_replace(chr(13),'',$POST['message']);
if(file_exists('gast.txt')){$ausgabe="\n";}
$comment=fopen('gast.txt','a');
$ausgabe.=$POST['name']."~".date("d M Y")."~".$POST['betreff']."~".$POST['message'];
fputs($comment,$ausgabe);
fclose($comment);
$POST['name']="";
$POST['betreff']="";
$POST['message']="";
}
?>
<html><head>
<title></title>
</head><body onLoad="goforit()">
<h3 align="center">Add a rotation to swap</h3>
<?php echo $fehler; ?>
<form action="<?php echo $SERVER['PHP_SELF']; ?>" method="post">
<p>
<input type="hidden" name="sent" value="1">
</p>
<p> </p>
<div align="center"></div>
<div align="center">
<table width="61%" height="62" border="0" cellpadding="2" cellspacing="0">
<tr>
<td align="center">your name, contact and qualification: <br> <input type="text" name="name" size="50" value="<?php echo $POST['name']; ?>">
</td>
<td><p align="center">Subject<br>
<input type="text" name="betreff" size="50" value="<?php echo $POST['betreff']; ?>">
</td>
</tr>
</table>
</div>
<p align="center"><br>
<strong>your swap</strong><br>
<textarea name="message" rows="5" cols="100" wrap="virtual">
<?php echo $POST['message']; ?>
</textarea>
</p>
<p align="center">
<input type="submit" value="send">
</p>
<p align="center"> </p>
<p align="center"><strong><font size="+1">Find a rotation to swap</font></strong></p>
</form>
<p align="center">
<?php
$eintrag=file('gast.txt');
$ausgabe="<br>";
$temp=count($eintrag)-1;
for($i=$temp;$i>=0;$i--)
{
$element=explode('~',$eintrag[$i]);
$ausgabe.="<table width=\"85%\" bgcolor=\"#00FF00\">";
$ausgabe.="<tr><td width=\"12%\"><b><font size=-1>".$element[1]."</b></td></font>";
$ausgabe.="<td width=\"49%\"><b><font size=-1>".$element[0]."</b></td></font>";
$ausgabe.="<td width=\"39%\"><b><font size=-1>".$element[2]."</b></td></tr></font>";
$ausgabe.="<tr><td colspan=\"3\"><font size=-1>".$element[3]."</td></tr></font>";
$ausgabe.="</table>";
}
?>
<?php echo $ausgabe; ?>
</body></html>
When I add after <?php echo $ausgabe; ?>
mail("myemailaddress",$message,$betreff);
I get a notification anytime somebody visit the guestbook. I just want a notification when a new message is posted.