I'm trying to get my code to display an error message when username field and password field are not filled. It doesn't work when i use If(isset) but when i use if (normal code) it seems to work. Any help will be appreciate it.Here is the code : Login.php\[code\]<?phpif (isset($_POST['log_username']) && isset($_POST['log_password'])){ $log_uname = preg_replace('#[^A-za-z0-9]', '', $_POST["log_username"]); $log_password = preg_replace('#[^A-za-z0-9]#i', '', $_POST["log_password"]); //get user from database $sql = mysql_query("SELECT * FROM users WHERE username='$log_uname' AND password='$log_password' LIMIT 1"); //check user existance $userCount = mysql_num_rows($sql); if ($userCount == 1) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; } $_SESSION['id'] = $id; $_SESSION['log_username'] = $log_uname; $_SESSION['log_password'] = $log_password; }else{ die (msg1(0, "Information Incorrect")); }}function msg1($status1,$txt1){ return '{"status1":'.$status1.',"txt1":"'.$txt1.'"}';}?>\[/code\]login.js\[code\]$(document).ready(function (){ $('.login_form').submit(function(e) { login(); e.preventDefault(); }); function login(){ hideshow1('loading1',1); error1(0); $.ajax({ type: "POST", url: "php/login.php", data: $('.login_form').serialize(), dataType: "json", success: function(msg1){ if(parseInt(msg1.status1)==1){ window.location=msg1.txt1; } else if (parseInt(msg1.status1)==0){ error1(1,msg1.txt1); } hideshow1('loading1',0) } }); } function hideshow1(el,act){ if(act) $('#'+el).css('visibility','visible'); else $('#'+el).css('visibility','hidden'); } function error1(act,txt1){ hideshow1('error1',act); if(txt1) $('#error1').html(txt1); }});\[/code\]and last Index.php\[code\] <?php include ("php/head.php");?><div id="wrapper"> <div id="container"> <div id="intro"> <h2><center>Are you a member? Login ...</center></h2> <h3><center>And enjoy hundreds of services.</center></h3> <div id="log_form"> <form action="php/login.php" method="POST" class="login_form"> <input type="text" size="25" name="log_username" id="login_txt" placeholder="Your Username"> <input type="password" size="25" name="log_password" id="login_pass" placeholder="Your Password"> <label id="check"><input type="checkbox" name="checkbox"> Remember Me</label> <input type="submit" name="submit1" id="login_sub" value="http://stackoverflow.com/questions/12738541/LogIn"> <img id="loading1" src="http://stackoverflow.com/questions/12738541/images/ajax-loader.gif" alt="working.." /> <script> $("#login_txt,#login_pass").click(function (e) { e.preventDefault(); $('#error1').fadeOut('fast', function () { $(this).show(); $(this).css("visibility","hidden"); }); }); </script> </form> <div id="error1"></div> </div> <div id="new_users"> <h4 class="h4_users">New Users ...</h4> <a href="http://stackoverflow.com/questions/12738541/#"><img src="http://stackoverflow.com/questions/12738541/#" width="55" height="55"></a> <a href="http://stackoverflow.com/questions/12738541/#"><img src="http://stackoverflow.com/questions/12738541/#" width="55" height="55"></a> <a href="http://stackoverflow.com/questions/12738541/#"><img src="http://stackoverflow.com/questions/12738541/#" width="55" height="55"></a> <a href="http://stackoverflow.com/questions/12738541/#"><img src="http://stackoverflow.com/questions/12738541/#" width="55" height="55"></a> </div> </div> <div id="register"> <h2><center>Sign up Below ...</center></h2> <h3><center>Easy, fast and free!</center></h3> <form action="php/register.php" method="POST" name="form" class="form"> <input type="text" size="25" name="fname" placeholder="First Name" id="fname" > <input type="text" size="25" name="lname" placeholder="Last Name"> <input type="text" size="25" name="username" placeholder="Username"> <input type="text" size="25" name="email" placeholder="Email"> <input type="text" size="25" name="email2" placeholder="Repeat Email"> <input type="password" size="25" name="password" placeholder="Password"> <input type="password" size="25" name="password2" placeholder="Repeat Password"> <input type="submit" name="submit" id="sub" value="http://stackoverflow.com/questions/12738541/Sign Up!"> <img id="loading" src="http://stackoverflow.com/questions/12738541/images/ajax-loader.gif" alt="working.." /> </form> <script> $('#fname').click(function (e) { e.preventDefault(); $('#error').fadeOut('fast', function () { $(this).show(); $(this).css("visibility","hidden"); }); }); </script> <div id="error"></div> </div> </div> <?php include("php/footer.php");?></div></body></html>\[/code\]