Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 239 Vote(s) - 3.41 Average
  • 1
  • 2
  • 3
  • 4
  • 5
- Paying 994 DZ Points -[Help] Writing to text file via php and overwriting it

#1
Well I'm very new to php and have been trying to learn what I stated in the above title ^, I need to figure out how to write to a php via link, example would be "

[To see links please register here]

?message=hi this is a test", but every time I write to it it'd over write the existing text in the text file. Does anyone know how I would go about doing this?

Also if you know how to do this without overwriting it, and just adding the next entry to a new line, that'd be awesome!
Reply

#2
Hmm, so you just need to write a string to a file via a link?


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Not exactly sure if that's what you were looking for as I don't completely understand your request. That's how you'd do it via file, and I'm not sure if PHP File I/O also includes seeking like in Python. If it does, and you want to be at the front of the program you'd do seek(0) or some variation in it with PHP.

You kept saying you were overwriting the file, and this is because when you open up a file with the 'w' or 'w+' permissions, it will automatically truncate all contents within it. Every language has it (Python, PHP, C++, etc). It's an OS problem, not the language itself. If you append the file, it doesn't delete the contents and that's the only way I really get around it.

edit;

If this doesn't work, or doesn't help you at all, please tell me. I'll keep looking into it so I can help you out as I want to know for my own benefit. Surprisingly, I can't get my head wrapped around it, but I'll try my best and research later if the information I've provided isn't beneficial to you at all. Though, it should be in the ballfield, so you may be able to get it done.
Reply

#3
I already got it from another person but if you still want the points you can have them. PM me if you do.
Reply

#4
Oh alright. Well, glad you got it fixed.
Reply

#5
Use some $_GET requests.

Something like:
<?php
#######
// By Fhoto, I'm bored k
#######
// File to write to, make sure the permissions are 777
$file_open = './logs.txt'
$message = $_GET['message']
// Use HTTP_CF_CONNECTING_IP -- If you're using Cloudflare
$ip = $_SERVER['REMOTE_ADRR'];
$file_write = 'Message:'.$message.' Sent by: '.$ip';
if(!isset($_GET['message'])) die('Error: Enter a message');
if(isset($_GET['message']))
file_put_contents(string $file_open , mixed $file_write);
?>
[/php]
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through