![]() |
|
[PHP] [PHP] I need a php file that creates another php/text file [HELP] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183) +---- Thread: [PHP] [PHP] I need a php file that creates another php/text file [HELP] (/showthread.php?tid=613160) |
[PHP] I need a php file that creates another php/text file [HELP] - SLAPYA - Aug 15, 2010 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. * - SLAPYA - Aug 15, 2010 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=filetocreate.txt?val2=texthere but that didn't work, does anyone know how i would do this * - ndee - Aug 15, 2010 Link: http://a1k.com/filecreator.php?val=filetocreate.txt&val2=texthere Code: PHP Code * - SLAPYA - Aug 15, 2010 thx bro...ill test it now. I think thats all i was looking for. A simple & sign between them lol * - redpenguin - Aug 16, 2010 + don't forget to chmod to 777? * - RadarX - Aug 16, 2010 Wouterkruze is right, if you don't set the chmod permissions to 777 you won't be able to write the text file. |