ISSET $_POST not working

<?php
include 'Header.php';
?>
<hr>
<div class="form">
    
    
    
    <?php
    if(isset($_POST['delete']))
{
    echo 'Delete Pressed!';
    $userObj=new users();
    $deleteID= $_POST['dID'];
    $deleteEmail=$_POST['dEmail'];
    
    echo $deleteID;
}else
{    echo 'Not pressed ';}

    ?> 
    <div class="studentManagement" align="center">
        <form type="POST" action="">
            
            <table id="Manage" >
                <tr>
                    <td colspan="2"><h1>Delete Student</h1></td>
                   
                </tr>
                 <tr>
                    <td>Student ID:</td>
                    <td><input type="Text" name="dID" placeholder="20220000"required/></td>
                </tr>
                <tr>
                    <td>Student Email:</td>
                    <td><input type="email" name="dEmail" placeholder="@student.polytechnic.bh"required/></td>
                </tr>
                
                <tr>
                    <td colspan="2" align="center">
                   <input type="Submit" value="Delete" name= "delete">
                    </td>
                </tr>
               
            </table>  
        </form>
     
    </div>
</div>

it is showing “not pressed” even after pressing delete

Use method='post' The type attribute is used for form fields, not the form tag. An empty action attribute is not actually valid. Leave the entire action attribute out of the form tag to cause the form to submit to the same page. Also, the post method form processing code should be above the start of the html document, not inside the html document.

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service