php - Serialized data being displayed -


i need make config file application, stumbled upon problem, tried solve couldn't find problem, code here works, except 1 thing, whenever submit form, save data, when reloads show serialized data stored in config.txt.

does know why happens , how can solve it

thanks -oedze

edit: explain more clearly: idee data stored in config.txt inputed in form, dont have add it, , can see values are. when press submit button, page save data in $config array, after save in config.txt, when done, reload page, post data removed users cache. but, whenever page reloads, it's showing a:1:{s:9:"groupname";s:4:"test";} instead of html page

<!doctype html> <html> <head>     <?php         function getconfig(){             $file = fopen("config.txt", "r");             $filedata = fread($file, filesize("config.txt"));             fclose($file);             $config = unserialize($filedata);              return $config;         }          function saveconfig($config){             $file = fopen("config.php", "w");             fwrite($file, serialize($config));             fclose($file);         }         if(isset($_get["updateconfig"])){             $config = array();             foreach($_post $key => $value){                 $config[$key] = $value;             }             saveconfig($config);             header("location: config.php");         }else{             $config = getconfig();         }        ?> </head> <body>     <h1>configuratie</h1>     <form method="post" action="config.php?updateconfig">     <table>         <tr class="optionsrow"><td class="optionsdata">groupname:</td><td class="optionsdata"><input type="text" name="groupname" value="<?php $config["groupname"]?>"></td></tr>         </table>     <input type="submit" value="opslaan">     </form> </body> </html> 

you have mistake on line : $file = fopen("config.php", "w");, config.txt , not config.php.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -