How to make php open a html-file, go two lines up, then write there and close? -


I am creating an elevator php-file to log some IP addresses. It is an IP address and date in an HTML file / Time-typing HTML file is going to be a table, so I want to like it:

  & lt; Table cellpadding = "6" rule = "group" frame = "no" & gt; & Lt; Thead & gt; & Lt; TR & gt; & Lt; Th & gt; IP & lt; / Th & gt; & Lt; Th & gt; Date & lt; / Th & gt; & Lt; Th & gt; Time & lt; / Th & gt; & Lt; / TR & gt; & Lt; / Thead & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; TD & gt; 192.168.0.1 & lt; / TD & gt; & Lt; TD & gt; 31. January 2009 & lt; / Td> & Lt; Td> 19: 21: 09 & lt; / Td> & Lt; / Tr & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;  

So to open this file, write the IP and date / time in the row above & lt; / Table & gt; to write, I already have php to write

I am a very newbie, I do not know where it is ... ..

This is my Is nearby:

P>

  & lt ;? Php $ ip = $ _SERVER ['REMOTE_ADDR']; $ Date = Date ("J. FY"); $ Time = date ("h: i: s"); $ File = fopen ('. / Iplogg.html', 'a', 1); $ Text = "& lt; tr & gt; & lt; td & gt; {$ ip} & lt; / td & gt; & lt; td & gt; {$ date} & lt; / td & gt; Lt; td & gt; {$ time} & lt; / td & gt; & lt; / tr & gt; \ n "; Filitt ($ file, $ text); Fclose ($ file); ? & Gt;  

I think the file has only one table. If there is more than one, then it will add to each.

  & lt ;? Php $ ip = $ _SERVER ['REMOTE_ADDR']; $ Date = Date ("J. FY"); $ Time = date ("h: i: s"); $ Text = "& lt; tr & gt; & lt; td & gt; {$ ip} & lt; / td & gt; & lt; td & gt; {$ date} & lt; / td & gt; Lt; td & gt; {$ time} & lt; / td & gt; & lt; / tr & gt; \ n "; $ Parent file = file_get_contents ('./iplogg.html'); $ NewFile = str_replace ('& lt; / table & gt;', $ text. '& Lt; / table & gt;', $ originalfile); File_put_contents ('. / Iplogg.html', $ newFile); ? & Gt;  

Edit Mix my suggestion with your code


Comments