How to save the running results in php? (not code)

now there is a file called 1.php
with the following code

<script src="http://pv.sohu.com/cityjson" ></script>
<script type="text/javascript">
   document.write("IP:"+returnCitySN.cip);
</script>
<br>
<script src="http://ip.ws.126.net/ipquery" ></script>
<script type="text/javascript">
      document.write(":"+ localAddress.province+"<br>:"+localAddress.city);
</script>

used to get the visitor ip
then how to record the IP, province and city after the visitor visit as txt
and post the entire file code as much as possible, thank you!

Php
Mar.25,2021

the front browser does not have permission to write files. You can use the file_put_contents function in PHP to write to 1.txt


mysql to learn about


.

if you want the client to save 1.txt
, you can download the file and let the user choose to save

.

if you want to save on the server side, you need to send a post request to the server using a php page or js, and then save it to the server with a file operation at the back end.

RE:
at the front end, you need to use ajax to send Post requests. Of course, there is also a lot of room to expand the back-end access records. For example, if you visit one file at a time, you can also open the file for appending. You can take some time to learn about fopen,fwrite and other file-related operations

.
// php


function saveUserIp($content,$append=0){

    $path     = 'folderName/';
    $name     = 'ipRecord';

    $filename = ($append ? $name : microtime(true) ).'.txt';


    $file     = fopen($path.$filename, $append?'a':'w') or die("!");

    fwrite($file, $content."\n");
    fclose($file);

}

//  
saveUserIp($postContent,1);

//  
saveUserIp($postContent);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3215e-2bdfc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3215e-2bdfc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?