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


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="fa        

Answers


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

Search




Leave an answer