mmarif4u Posted December 26, 2007 Share Posted December 26, 2007 I am doing condition check, but not sure,that why its not work. <form action='' method='post'> <input type='text' name='n'> <br> <input type='text' name'e'> <input type='submit' name='submit' value="Test now"> <br> </form> <?php if($_POST['submit']){ $name="1"; $n=$_POST['n']; $email="2"; $e=$_POST['e']; if(($name != $n) && ($email != $e)){echo "Sori";}else{echo "matched";} } ?> This is sample code.if i check it against both it says matched,if with 1st textbox(2nd will be blank) also says matched.till to here its fine. But if i want to check the 2nd textbox(1st will be blank),it prints Sori. Mean the condition is not true. I want if both r filled or either 1 but it go ahead. Any ideas. I know its very simple,But my mind stuck here. Quote Link to comment https://forums.phpfreaks.com/topic/83201-solved-simple-check/ Share on other sites More sharing options...
trq Posted December 26, 2007 Share Posted December 26, 2007 it helps if you format your code so it is readable. <?php if (isset($_POST['submit'])) { $name="1"; $n = $_POST['n']; $email = "2"; $e = $_POST['e']; if (($name != $n) || ($email != $e)) { echo "Sorry"; } else { echo "matched"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/83201-solved-simple-check/#findComment-423228 Share on other sites More sharing options...
mmarif4u Posted December 26, 2007 Author Share Posted December 26, 2007 Tq Thorpe for rearranging it. 1 thing i forgot to post. I also tried the following samples: if (($name != $n) || ($email != $e)) if (($name == $n) && ($email == $e)) if (($name == $n) || ($email == $e)) but still no luck... Quote Link to comment https://forums.phpfreaks.com/topic/83201-solved-simple-check/#findComment-423230 Share on other sites More sharing options...
Ken2k7 Posted December 26, 2007 Share Posted December 26, 2007 <input type='text' name'e'> You missed an equal sign in the name attribute. <input type='text' name='e'> Use empty() to check if any $_POST values are nulled or have no value. Quote Link to comment https://forums.phpfreaks.com/topic/83201-solved-simple-check/#findComment-423254 Share on other sites More sharing options...
mmarif4u Posted December 26, 2007 Author Share Posted December 26, 2007 Tq... This 1 done the job. <input type='text' name='e'> I mis the = sign. Quote Link to comment https://forums.phpfreaks.com/topic/83201-solved-simple-check/#findComment-423270 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.