Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

[PHP] I need a php file that creates another php/text file [HELP]

Hey guys. I am needing to create a textfile that creates these things:

- a php file with code in it
- a text file with text in it

can someone please help me with this.
hey...thank you for the answer for the php question. One more thing that I need to know tho that u may be able to answer is this...

When i create the file, I am going to need a different name and text each time.

I used this code to write different text to a file each time:

<?php
$myFile = "http://a1own.com/Ulalonnection.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = str_replace('%newline%', "\n", $_GET['val']);
fwrite($fh, $stringData);
fclose($fh);
?>

this way...whenever i went here:
http://a1own.com/filewriter.php?val="textToWriteHERE"

i was able to write that text to the file. This made it dynamic.
How would i make the file created and text in the file dynamic?

ok...so i did this

<?php
$pathfile= $_GET['val'];
$text="Hello world";
$fp = fopen($pathfile, "a+");
fwrite($fp, "$text\r\n");
fclose($fp);
?>

and when i went here: http://a1k.com/filecreator.php?val=filetocreate.txt

it worked and i was able to create dynamically named files. But now I want to also be able to change the text that is written in them. I tried using the same method and then simply doing...

http://a1k.com/filecreator.php?val=filet...2=texthere

but that didn't work, does anyone know how i would do this
Link: http://a1k.com/filecreator.php?val=filet...2=texthere
Code:
PHP Code

<?php
$pathfile
= $_GET['val'];
$text = $_GET['val2'];
$fp = fopen($pathfile, "a+");
fwrite($fp, "$text\r\n");
fclose($fp);
?>
thx bro...ill test it now. I think thats all i was looking for. A simple & sign between them lol
+ don't forget to chmod to 777?
Wouterkruze is right, if you don't set the chmod permissions to 777 you won't be able to write the text file.
[Image: ICmhDgc.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Javascript]  by HiddenWarriorJun 26, 2016 12:51 PM 1 220 Jun 26, 2016 12:51 PM
Last Post: Skullbone
[PHP] by 'An0nyApr 25, 2015 10:03 AM 3 117 Apr 25, 2015 10:03 AM
Last Post: 'An0ny
[Javascript]  by OrgyJan 11, 2014 12:21 PM 2 185 Jan 11, 2014 12:21 PM
Last Post: Orgy