Execute javascript after submitting PHP [closed]

1

I'm trying to run a PHP function after submitting the page, but I have not been successful. Could someone help me?

    <?php
function teste() {
?>
    <div>
        <p>
            <?php echo "Foi clicado"; ?>
        </p>
    </div>
<?php   
}
?>

<body>       

    <!--FILTRO FLUTUANTE -->
    <div id="mws-themer">
        <div id="mws-themer-hide"></div>
        <div id="mws-themer-content">
            <div class="mws-themer-section">
                <form action="?a=ok" name="myForm" id="myForm" style="padding: 0; margin: 0;" method="POST">
                    <input type="text" name="edtMFIR" id="edtMFIR" value="" class="mws-textinput error">
                </form>
            </div>
            <div class="mws-themer-separator"></div>
            <div class="mws-themer-section">
                <button type="submit" class="mws-button red small" id="mws-themer-sendfilterPCD">Filtrar</button>
            </div>
        </div>
    </div>

    <?php
        if (isset( $_GET['a'] ) && $_GET['a'] == 'ok' && $_POST['texto'] != '') {
            teste();
        }
    ?>
    
asked by anonymous 20.09.2017 / 15:06

1 answer

1

Your submit button is out of form , so store it in the form tag, if it affects anything in your layout, submit it through the javascript example ...

<!--FILTRO FLUTUANTE -->
    <div id="mws-themer">
        <div id="mws-themer-hide"></div>
        <div id="mws-themer-content">
            <div class="mws-themer-section">
                <form action="?a=ok" name="myForm" id="myForm" style="padding: 0; margin: 0;" method="POST">
                    <input type="text" name="edtMFIR" id="edtMFIR" value="" class="mws-textinput error">
                </form>
            </div>
            <div class="mws-themer-separator"></div>
            <div class="mws-themer-section">
                <button type="button" onclick="submit()" class="mws-button red small" id="mws-themer-sendfilterPCD">Filtrar</button>
            </div>
        </div>
    </div>

<script>
function submit() {
    document.getElementById("myForm").submit();
}
</script>
    
20.09.2017 / 15:16