Home Ask Login Register

Developers Planet

Your answer is one click away!

Mia February 2016

PHP - Page needs Twice a Submit to show Changes

I have the most annoying PHP ever encountered. I need to submit the page TWICE before the changes are being made to the page. For example; if you submit the page when you enable a tool, it will show the tools' settings: for these settings to show up you need to submit the page twice. What is wrong with this code?

Another example: enter image description here


if (isset($_POST["submit"]))
    $string = '<?php
    $customoptions = ' . $_POST["customoptions"] . ';
    $primarycolor = "' . $_POST["primarycolor"] . '";
    $adminbg = "' . $_POST["adminbg"] . '";

    $fp = fopen("includes/userstyle.php", "w");
    fwrite($fp, $string);
   <form action="" name="customopt" method="post">
            <td>Panel language</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>
            <td>Custom Style</td>
                <select name="customoptions" id="customoptions">
                    <option <?php echo ($customoptions == true) ? 'selected' : '' ?> value="true">
                        <?php echo $lang['enabled']; ?>
                    <option <?php echo ($customoptions == true) ? 'selected' : '' ?> value="fa        


Jimmy Canadezo February 2016

OK, try to do it has to do with the top that says if (isset($_POST['submit'])) Try and give it a default value if it isn't set. if (!(isset($_POST['submit']))) I'm referrin to the $customoptions variable $primarycolor and $adminbg

Post Status

Asked in February 2016
Viewed 2,504 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life