Jump to content

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

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...

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.