//write text.php
// Get the user details.
$getdate = date( 'd-m-Y, H:i:s' );// Get the date.
$user_ip = $_SERVER['REMOTE_ADDR'];// Get the users IP.just in case
$referer = getenv("HTTP_REFERER");// Get the refering page. just in case
// Look for the text file and open it for writting.
$file = "./logfiles/logfile.csv";// define the text file. Note I am using a .csv file, it is still text but opens in excell for manipulation when I remember to check it
$fp = fopen($file, "a+");//open the text file for writing.
// Write into the text file.
fputs ($fp, "$user_ip,$getdate, $referer, $data1, \n"); //$data1 can be any number of data fields required to match the form,
fclose($fp);// Close the text file.
The scrap above can be appended to any php form and write to the texfile as part of the php form processing, checking IP and referrer helps reduce obvious dodgy entries.
Javasript on the user side, and php at the server, is pretty much AJAX, and can do really impressive things, the form handlers you look for may be for download at hotscripts, sourceforge, javascript.net or one of the other script repositories
If(!$referer==$_SERVER['php_self']) die('data must submitted from the online form'); just crossed my mind assuming this is a self processed form (action='<?php echo $_SERVER['PHP_SELF']; ?>')
Last edited by almostbob; Jan 11th, 2009 at 1:09 am.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved