php - validation always showing enter all fields -
the problem whenever loading page, getting enter fields, there anyway bypass whenever load page first time.
<form action="brand_upload.php" method="post" enctype="multipart/form-data"> <label for="file">filename(logo):</label> <input type="file" name="file" id="file"><br> <br>brand:<input type="text" name="brand"> <br>serial no.:<input type="text" name="serial_number"> <input type="submit" name="submit" value="submit"> <?php if (isset ($_post['submit']) && isset($_post['brand']) && isset($_post['serial_number']) && !empty($_post['brand']) && !empty($_post['serial_number'])){ { echo 'do something'; } else { echo '<br>enter fields'; } ?> </form>
you can check if request method post
<?php if($_server['request_method'] == 'post'){ if (isset ($_post['submit']) && isset($_post['brand']) && isset($_post['serial_number']) && !empty($_post['brand']) && !empty($_post['serial_number'])){ { echo 'do something'; } else { echo '<br>enter fields'; } } ?>
Comments
Post a Comment