html - PHP - Page needs Twice a Submit to show Changes -


i have annoying php ever encountered. need submit page twice before changes being made page. example; if submit page when enable tool, show tools' settings: these settings show need submit page twice. wrong code?

another example: enter image description here


code:

<?php if (isset($_post["submit"])) {     $string = '<?php     $customoptions = ' . $_post["customoptions"] . ';     $primarycolor = "' . $_post["primarycolor"] . '";     $adminbg = "' . $_post["adminbg"] . '";     ?>';      $fp = fopen("includes/userstyle.php", "w");     fwrite($fp, $string);     fclose($fp); } ?>    <form action="" name="customopt" method="post">     <table>         <tr>             <td>panel language</td>             <td>                 <select onchange="this.options[this.selectedindex].value && (window.location = this.options[this.selectedindex].value);">                     <option><?php echo $lang['chooselanguage']; ?></option>                     <option value="dashboard.php?lang=en">english</option>                     <option value="dashboard.php?lang=nl">dutch</option>                 </select>             </td>         </tr>         <tr>             <td>custom style</td>             <td>                 <select name="customoptions" id="customoptions">                     <option <?php echo ($customoptions == true) ? 'selected' : '' ?> value="true">                         <?php echo $lang['enabled']; ?>                     </option>                     <option <?php echo ($customoptions == true) ? 'selected' : '' ?> value="false">                         <?php echo $lang['disabled']; ?>                     </option>                 </select>             </td>         </tr>         <?php         if ($customoptions)         {             ?>             <tr>                 <td>primary color</td>                 <td><input name="primarycolor" type="text" id="primarycolor" value="<?php echo $primarycolor; ?>"></td>             </tr>             <tr>                 <td>background color</td>                 <td><input name="adminbg" type="text" id="adminbg" value="<?php echo $adminbg; ?>"></td>             </tr>             <?php         }         ?>     </table>     <input type="submit" name="submit" value="<?php echo $lang['ok']; ?>"> </form> 

ps: know isn't way save settings in php file test, never go live.

ok, try has top says if (isset($_post['submit'])) try , give default value if isn't set. if (!(isset($_post['submit']))) i'm referrin $customoptions variable $primarycolor , $adminbg


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -