• Well I have some php code that has a button that updates some text in .txt file. So I installed the plug-in Exec-PHP and I copied my code into the edit view on my page and the button shows up. So far the php plug-in is doing its job. Now for some reason when I click on my button to change the text on a file it redirects me back to my blogs main index.php page. When using this code on a normal .php page it works great. But when using it in wordpress something with how the page is displayed like http://mysite.com/wordpress/?page_id=3 it doesn’t work.

    Does anyone have any ideas on either how to create a new separate page or for this code to work properly?

    Here is code, hopefully it shows up correctly:

    <?php
    if($_POST['Submit']){
    $open = fopen("test.txt","a+");
    $text = "Left\n";
    fwrite($open, $text);
    fclose($open);
    header("Location: {$_SERVER['PHP_SELF']}");
    }
    
    echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
    echo "<input name=\"Submit\" type=\"submit\" value=\"Left\" />\n
    </form>";
    ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘php code not working properly’ is closed to new replies.