Jump to content

Avendium

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Avendium's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I managed to load the file as an array and display the line that i want but im having trouble inputing the value that i get from my form back into the array. Form code [code]<form action="test.php" method="POST"> name: <input type="text" name="name" /> <input type="submit" value="Submit"/> </form>[/code] PHP code [code]<?     $filename = 'test.txt'; //filename              if (file_exists($filename)) {         $data = file($filename, 'r+'); //Initialize array         //debug         echo $data[0];              } else {            echo "The file $filename does not exist";     break; } ?>[/code] my txt file has the lines line0 line1 line2 line3 I can display them fine but im having trouble trying to figure out how to place the input back into the file to replace line1 which would be $data[1] in the array. What kind of write function should i use?
  2. hmm, this would work if i knew what "data2" was in order to replace it. The problem is, data 2 could be anything. Is there anyway to just target and replace the whole line without knowing what is there to begin with? and without replacing the first line? what im trying to do is this: I have my form in form.php. I want to send the data to my data.txt, on the line designated for that perticular form, in this case its line 2. So whenever the user inputs a new value, line 2 would be replaced with that new input. so i never know what line 2 holds to replace it. thanks for your help.
  3. How would go about taking a value from a form object and printing it on a line that I choose in an external file? for example. If i have the following in my external file, data.txt. data1 data2 data3 data4 and i want the user to input a value and that value be written on line 2 so that when the submit button is pressed the txt will now show. data1 (whatever the input was) data3 data4 thanks
  4. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Wow, I rarely see a question posted like this... Nice [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] [/quote] I write alot of tutorials [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] not used to asking questions. Your solution fixed my problem, Thanks.
  5. Ok, im gonna try and simplifiy my explination as much as possible to make sure you guys understand what I want to do. Heres the deal. Im making a site where every aspect of it can be edited from an external file. Before I explain my problem. Im gonna try explain what I want to do. Heres a text example of how my server is setup right now in terms of folders and php files. *note, following is not my code, I just used the code quotes to keep the formating. [code]   ROOT--------> index.php               [Folder: System] ------> [Folder: Engine]----------------------->engine.php                                        [Folder: Modules]------>[Folder: Menu]---->menu.php[/code] So the Url's for the files are: Short urls examples index.php System/Engine/engine.php System/Modules/Menu/menu.php Full urls examples [a href=\"http://www.websiteURL.com/index.php\" target=\"_blank\"]http://www.websiteURL.com/index.php[/a] [a href=\"http://www.websiteURL.com/System/Engine/engine.php\" target=\"_blank\"]http://www.websiteURL.com/System/Engine/engine.php[/a] [a href=\"http://www.websiteURL.com/System/Modules/Menu/menu.php\" target=\"_blank\"]http://www.websiteURL.com/System/Modules/Menu/menu.php[/a] In my engine.php. I have the following example of code. [code]<? $MenuURL = '/System/Modules/Menu/Menu.php'; //Menu Module URL ?>[/code] In my Index.php. I have the following example of code in the header [code]<? include ('/System/Engine/Engine.php');?>[/code] and then i have this code where i want my menu to appear [code]<?php include ($MenuURL);?>[/code] This setup works fine. The engine is loaded into the index and then menu.php loads the variable url and the menu shows up. The problem with this however is if i wanted to put the menu in another page I wouldnt be able to because the url in the engine is based from the root of the of the server. Is there a way to make the include() command to be rerouted back to the root of the server and then locate the file from there? I tried using this: [code]<?php include ($_SERVER['DOCUMENT_ROOT'].($MenuURL));?>[/code] And it worked on my apache test server but the urls in the source code started from the c:\ all the way to my apache www directory and then adds on the url from the engine to the end of it completing the Url. When I tested this on an online server. It didnt work. What is wrong with the code? Is this even possble to do and if not what do you think is the best way I should go about this in order to get my files working together like so: [img src=\"http://revonet.org/stuff/leonix/engine.gif\" border=\"0\" alt=\"IPB Image\" /] Please help, and Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.