Jump to content

Php File Append Write To Itself..?


cyfer65

Recommended Posts

Is it possible for a PHP file to Append Write to itself..?I want to make it so that if a password is added into the server_query along with some other data, then that data will be added into a new entry in an already existing array inside the PHP file..How would I do that if its possible..?

Link to comment
Share on other sites

what are you trying to do actualy? it is not good idea to edit the page itself. there must be an other way to solve your problem.

Link to comment
Share on other sites

I just want to be able to quickly add/append and element to an array inside the PHP file quickly by using just the server_query but restricting the access to only allow it if my password is included in the server_query...So if I put this in the URL http://website.com/?CCCC&PW=MyPasswordthen it would add/append 'CCCC' to the array in my index.php file like this:$ARRAY[] = 'AAAA';$ARRAY[] = 'BBBB';$ARRAY[] = 'CCCC';

Link to comment
Share on other sites

you dont need to add it on same php file. you can write it in separate file http://php.net/funct...le_put_contents when pwrod matches and then you can get the file data using http://php.net/funct...le_get_contents or http://php.net/function.file to work with them later. file() reads a file and return it in array more info on that link apart from that you can use database also as synook pointed. with small amount of data it is ok to use files but when the data is realy expanded and complicated it is more likely better to use any database.

Link to comment
Share on other sites

It's probably easier to serialize and unserialize the array. Store the serialized array in an include file as a string, include the file and unserialize the string to turn it back into an array, add your values to the array, and write the serialized array back to the file.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...