Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can I add data to url and txt file on my website?

What I have tried:

<?php

$who=$_GET["text"];
if (! empty($who)){
$old=file_get_contents("weblog.txt");
$new= $eski. "" . $who ;
file_put_contents("sitelog.txt",$new);
echo"Success";
}

?>

I saved this as log.php

website.com/text?=123

The text "123" is saved in the weblog.txt file,
but when I try another text again it replaces it with the old one
I want to add, instead of changing
I'm waiting for your help
Posted
Updated 5-Sep-17 16:36pm
Comments
Peter_in_2780 5-Sep-17 22:32pm    
You could help yourself by reading the documentation on file_put_contents()
CL4Y3R-TR 6-Sep-17 1:50am    
I do not know very well in web programming, can you share by changing the necessary places

1 solution

First of read the following link: PHP: file_put_contents - Manual[^]

You are missing the append option. And also consider using a new line end of every log.
 
Share this answer
 
Comments
CL4Y3R-TR 6-Sep-17 1:53am    
I do not know very well in web programming, can you share by changing the necessary places
Mohibur Rashid 6-Sep-17 2:14am    
This is not about web programming. This is about reading the documentation and understanding source code
file_put_contents("sitelog.txt",$new, FILE_APPEND);
CL4Y3R-TR 6-Sep-17 2:50am    
file_put_contents("sitelog.txt",$new, FILE_APPEND);

this

dosya_get_contents ("weblog.txt");

I will change this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900