In a PHP Code, when i am trying to validate basic login validation (empty field, numeric field, etc.), my page gets refresh and all the already entered data gets away. My sample code:
if(isset($_POST['Submit']))
{
// username and password sent from form
$MailId=$_POST['MailId'];
$Password=$_POST['Password'];
if(empty($_POST['MailId']))
{
$MerrorMessage = "You forgot to enter a MailId!";
}
else if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/", $MailId))
{
$MailformaterrorMessage = "Email ID format is not correct!";
}
if(empty($_POST['Password']))
{
$PerrorMessage = "You forgot to enter a Password!";
}
else
{
main Logic
.....
}
Any suggestions if without using Javascript, page refresh can be avoided ?