Jump to content

[SOLVED] Simple check


mmarif4u

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/83201-solved-simple-check/
Share on other sites

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";
    }
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/83201-solved-simple-check/#findComment-423228
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.