Peuplarchie
05-22-2007, 09:00 PM
I'm posting data trough a form and adding it to an html file with the following :
<?php
echo "copiage de fichier debut";
// your new data + newline
$new_line = stripslashes($_POST['codesource'])."\n\r";
// the filepath
$file = 'upload/aaatest.html';
// the old data as array
$old_lines = file($file);
// add new line to beginning of array
array_unshift($old_lines,$new_line);
// make string out of array
$new_content = join('',$old_lines);
$fp = fopen($file,'w');
// write string to file
$write = fwrite($fp, $new_content);
fclose($fp);
echo "copiage de fichier Fin";
echo "Redirection.....";
?>
this code add "codesource" to "upload/aaatest.html"
It add it to the bigginig of the file, How can I choose the line "codesource" is added within the file , ex : count 100 lines and start adding text after 100 lines ????
I also need this code to add a log part,
It would add to the source code of the html file, in comment, the time&date, the ip, the name, email.
I know how to show the time or ip of a user on screen but i don't want it to be seen, only in the sourcecode of the html, as logs ????
<?php
echo "copiage de fichier debut";
// your new data + newline
$new_line = stripslashes($_POST['codesource'])."\n\r";
// the filepath
$file = 'upload/aaatest.html';
// the old data as array
$old_lines = file($file);
// add new line to beginning of array
array_unshift($old_lines,$new_line);
// make string out of array
$new_content = join('',$old_lines);
$fp = fopen($file,'w');
// write string to file
$write = fwrite($fp, $new_content);
fclose($fp);
echo "copiage de fichier Fin";
echo "Redirection.....";
?>
this code add "codesource" to "upload/aaatest.html"
It add it to the bigginig of the file, How can I choose the line "codesource" is added within the file , ex : count 100 lines and start adding text after 100 lines ????
I also need this code to add a log part,
It would add to the source code of the html file, in comment, the time&date, the ip, the name, email.
I know how to show the time or ip of a user on screen but i don't want it to be seen, only in the sourcecode of the html, as logs ????