PHP form not working WHY? IT must warn user if blanks are empty
<?php $loginerr = $websiteerr = $messageerr = $emailerr = $mavzuerr=""; $login = $website = $message = $email = $mavzu = ""; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (empty($_POST['login'])){ $loginerr = "Loginni kiritish majburiy"; } else { $login = test_input($_POST['login']); } if(empty($_POST['email'])){ $emailerr = "Emailni kiritish majburiy"; } else { $email = test_input($_POST['email']); } } function test_input($data) { $data = trim($data); $data = stripcslashes($data); $data = htmlspecialchars($data); return $data; } ?> <html> <form> <input type="text" name="login" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post"> <span class="error"><?php echo $loginerr;?></span> <input type="email" name="email" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post"> <span class="error"><?php echo $emailerr; ?></span> <input type="submit" value="Submit"> </form> <?php echo $login; echo $email; ?> </html>