Ok, I am playing around with editing a flat file database from my site (in an admin capacity). I have 5 different files I need to edit. I am using the same exact code on all 5 except for the names of the files. I have one that refuses to work and i can't figure out why.
The way it works is the file is opened in a textbox where I can make necessary changes, then you hit the submit query button and the changes are saved and the page reopened to show the changes. On this particular page, clicking submit causes the page to go blank.
I can reopen the page but the changes aren't made. All 4 of the other pages with exactly the same code work perfectly...
Here's the code....
<?php $myfile = "../../cgi-bin/xxxxxxxx/adminpermitdb.txt"; if (isset($_POST['ta'])) { $newData = ($_POST ['ta']); $handle = fopen($myfile, "w"); fwrite($handle, $newData); fclose($handle); } ?> <?php if (file_exists($myfile)) {
$mydata = file_get_contents($myfile); }
?> <html lang="en"> <head> <title>Approved Permit Edit</title> <style type="text/css"> <!-- body { color:#000000; background-color:#FFFFFF; } a { color:#0000FF; } a:visited { color:#800080; } a:hover { color:#008000; } a:active { color:#FF0000; } --> </style> </head> <body> <br><br>
<form action="adminpermitdb.php" method="POST"> <--- this is the name of the edit page. <textarea name="ta" cols="120" rows="25"><?php echo $mydata; ?></textarea> <br /><br /> <?php $url = htmlspecialchars($_SERVER['HTTP_REFERER']); <---- a back button I installed to make navigation easier. echo "<a href='$url'>I Screwed Up - Get Me Outa Here!</a>"; ?> <br><br><br><br> <input name="Button" type="Submit" />
</form> </body> </html>
http://towtalk.net ... Hosted by Zarconia.net! |
is the directory where the file is stored has permission 777 ? so much to do.... |
On mine, it's 755. All 4 of the other files are in the same directory and they work fine. I just tested it again and I can get it to change the file if I hit the refresh button on the browser, (returns the same blank page) then highlight the url and hit enter to reload the page. THEN it makes the changes.
It's just weird enough to make me pull my hair out. I've compared all the files using my editor just to make sure I didn't miss an apostrophe or something. They are all exactly the same.
I even went so far as to make a new adminpermitdb text file just in case there was some weird ownership problem
http://towtalk.net ... Hosted by Zarconia.net! |
can we have codes in adminpermitdb.php. And are all files are posting data to this file? so much to do.... |
i guess the code is of that file....lol
try this
<form action="adminpermitdb.php" method="POST"> <--- this is the name of the edit page. <textarea name="ta" cols="120" rows="25"><?php echo $mydata; ?></textarea> <br /><br />
to
<form action="" method="POST"> <--- this is the name of the edit page. <textarea name="ta" cols="120" rows="25"><?php echo $mydata; ?></textarea> <br /><br />
remove the file name.
so much to do.... |
http://towtalk.net ... Hosted by Zarconia.net! |
It's a friggin simple piece of code. Driving me batty.
Farck it, goin to bed. Will deal with it tomorrow. Thanks for the help.
http://towtalk.net ... Hosted by Zarconia.net! |
I try to edit a txt file on my localhost and it worked perfectly. I think something on the server is a problem. You can still try to make it that way so the form will submit the data to another file and that file do the writing process. It will be simple. so much to do.... |
can we have codes in adminpermitdb.php. And are all files are posting data to this file?
No. Strictly text only txt files. Very basic stuff. Has delimiters ( | ) and a specific number of columns so the file can be copied and imported into excel when we want to do serious work on the data. . I even removed the htmlspecialchars notation so it would stop dropping <br /> tags at the end of each line. I'd post a sample but the lines are full of names and addresses of customers.
I also changed the txt file and php file name to just adminpermit.txt/php.
http://towtalk.net ... Hosted by Zarconia.net! |
Maybe there's some weird filter on the word admin. Have a lot of odd trouble with HFW lately. I'll try removing that from the name tomorrow. Everything points to the name of the files. http://towtalk.net ... Hosted by Zarconia.net! |
Ok, this is just freaky.
It has to be the content of the data file. There is just no other explanation for why this happens. There are literally 100's of lines of data in this file, I guess I'm going to go through it line by line and see if i can spot something.
I just added 2 more flatfile databases and they also both work perfectly using this setup.
It almost has to be one row with the wrong amount of columns but i can't see how because it would throw an error and report it. I can see it now, I'm gonna learn me sumthin new tonight.
http://towtalk.net ... Hosted by Zarconia.net! |
Sky,
Refresh my memory, is mod_security running on the server but turned off in certain directories using .htaccess commands? If the answer is YES then are these files in a directory where is ISN'T turned off?
Did you get a chance to try renaming the file and taking out admin yet?
BoonEx Certified Host: Zarconia.net - Fully Supported Shared and Dedicated for Dolphin |