-1

I'm using a standard form in combination with two if constructs and I am not sure if the syntax are ok. Is there a better way to refactor the following code?

if(!isset($_POST['submit']))
   {
 
   }

if(isset($_POST['submit']))
   {
 
   }


<form class="mt20" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >

    <input type="submit" name="submit" value="speichern">

</form>

Pressing the submit button the site should be reloaded and the code within the if(!isset( ... bracket should not be executed. For hundreds of users the code is not executed. But there is one user where the code is executed.

zcoop98
  • 2,590
  • 1
  • 18
  • 31

2 Answers2

0

This should help you explain

Also if possible just do a if/else conditional instead of doing two checks which is redundant and confusing. I think that one user might be artificially manipulating the data and passing in NULL thus triggering the !isset

Community
  • 1
  • 1
mrpanda
  • 104
  • 5
-2

You can do as:

if (!isset($_POST['submit'])) {

} else {
    if (isset($_POST['submit'])) {

    }   
}
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Hamza
  • 37
  • 8