• I want the form data to be sent to test.php with the redirection. I can help someone. Thank you.

    This is the code:

    <?php
        if(isset($_POST['btn'])){
            //do some task
        ?>
        <script type="text/javascript">
            var e = document.getElementById('testForm'); e.action='test.php'; e.submit();</script>
        <?php
        }
        ?>
    <form name="testForm" id="testForm"  method="POST"  >
        <input type="submit" name="btn" value="submit" autofocus  onclick="return true;"/>
     </form>

    I asked for help on several forums including many StackOverflow but no response. I hope someone here can help me…

  • The topic ‘how to write javascript code inside php?’ is closed to new replies.