Only will be needed of 3 files:
- 1 html/php file containing the form
- 1 php file for processing the form data
- 1 html/txt file for output
Additionally, I recommend to give to the output file a hard to imagine name, cuz it's supposed you dont wanna let everybody to read it
Well, imagine your WebServer is at C:\Web\, well, you could embed the form and processing pages into your existing pages, but you also could name the formpage as form.php, the processing page as form2.php, and finally the output file as output_contact_form.html (I highly recommend to use html pages for output).
OK, lets start, you have to do a form into the form.html page, and set the name of the fields, etc.
i.e.: (3 fields is OK for contact sheets: Name, Mail, and the text, and is nice to include the client IP first if you're going to save it, if the page was PHP)
CODE
<html>
<body>
<form method="post" action="form2.php">
<p>Your name<input type="text" name="name"></p>
<p>Your e-mail<input type="text" name="mail"></p>
<p>Text to send<input type="text" name="text"></p>
<p>Logged IP: <? echo $_SERVER['REMOTE_ADDR'] ?>
<p><input type="submit" value="Go!"></p>
</form>
</body>
</html>
<body>
<form method="post" action="form2.php">
<p>Your name<input type="text" name="name"></p>
<p>Your e-mail<input type="text" name="mail"></p>
<p>Text to send<input type="text" name="text"></p>
<p>Logged IP: <? echo $_SERVER['REMOTE_ADDR'] ?>
<p><input type="submit" value="Go!"></p>
</form>
</body>
</html>
Then the processing page (it will write to the output file, without caring if all the fields were filled out, only will ste the blank field to "not filled")
CODE
<html>
<body>
<?
$file=fopen('output_contact_form.html','a'); /*'a' stands for read/write permission, moving the cursor to the
last character, so it will look nice cuz it will look like a list of Reports */
$ip=$_SERVER['REMOTE_ADDR'];
$date=date('H:i:s m-d-Y'); // the date in PHP format, if you wanna include it
if (!$_POST['name']) {
$name='not filled';
}else{
$name=$_POST['name'];
}
if (!$_POST['mail']) {
$mail='not filled';
}else{
$mail=$_POST['mail'];
}
if (!$_POST['text']) {
$text='not filled';
}else{
$text=$_POST['text'];
}
// under this lines, you can set the format for the output, i'll put a lil example
$text_to_output='<br><font size="3" face="Verdana, Arial" color="#000000"><hr><br><p><b>'.$name.'</b> <font size="2">
('.$mail.', '.$ip.', '.$date.')</p><p>'.$text.'<br><br>';
// then, we put it into the file...
fputs($file,$text_to_output);
// ...and echo a Sent Msg
echo '<br><p align="left">Message Sent.</p>';
?>
<body>
<?
$file=fopen('output_contact_form.html','a'); /*'a' stands for read/write permission, moving the cursor to the
last character, so it will look nice cuz it will look like a list of Reports */
$ip=$_SERVER['REMOTE_ADDR'];
$date=date('H:i:s m-d-Y'); // the date in PHP format, if you wanna include it
if (!$_POST['name']) {
$name='not filled';
}else{
$name=$_POST['name'];
}
if (!$_POST['mail']) {
$mail='not filled';
}else{
$mail=$_POST['mail'];
}
if (!$_POST['text']) {
$text='not filled';
}else{
$text=$_POST['text'];
}
// under this lines, you can set the format for the output, i'll put a lil example
$text_to_output='<br><font size="3" face="Verdana, Arial" color="#000000"><hr><br><p><b>'.$name.'</b> <font size="2">
('.$mail.', '.$ip.', '.$date.')</p><p>'.$text.'<br><br>';
// then, we put it into the file...
fputs($file,$text_to_output);
// ...and echo a Sent Msg
echo '<br><p align="left">Message Sent.</p>';
?>
That should work

