//line 2 is at the begining of the if statement
 <?php
        if (isset($_POST = 'submitted')){
//code here
  }
    ?>
//line 2 is at the begining of the if statement
 <?php
        if (isset($_POST = 'submitted')){
//code here
  }
    ?>
 
    
    Obvioulsy what you need is
if (isset($_POST['submitted'])) {
    // code here
}
isset($_POST['submitted']) checks if key 'submitted' isset in your $_POST array.
In your code
if (isset($_POST = 'submitted')) {
isset checks the result of assigning value 'submitted' to $_POST. But the result of assignment is some value, and this value can not be checked if it is set. As a side effect your $_POST is overwritten and you lose all your data inside it.
