I am trying to submit a php form to self but after submit the page returns the source code of the page and not the processed data.
I have a issset to check if the form has been submitted and then have functions on the same page to process the submitted data.
Here is the code:
    if(isset($_POST['submit'])){
        if ($_POST['name' == 'px']) {
            $pxValue = $_POST['value'];
            $value = convertToEm($pxValue); 
        }
        if ($_POST['name' == 'em']) {
            $emValue = $_POST['value'];
            $value = convertToPx($emValue); 
        }
        function convertToEm($value) {
            $base_font = 16;
            $em_value = $value / $base_font;
            return $em_value;
        }
    }
Here is the form:
<form action="" id="converterPx" method="POST">
    <h3>Convert Pixels to Ems:</h3>
    <label>PX:</label>
    <input type="text" name="value" value="" />
    <?php echo 'Result:'. $value; ?>
    <input type="hidden" name="type" value="px" />
    <input type="submit" name="submit" id="submit-px" />
</form>
Trying to get the form processed on the same page
Using the Browser Inspector, i see that the POST is submitted with values.
Any help with this would be great
 
     
     
     
     
    