php - Only ahow error message when error occurs -


i creating calculator on web challenge ability think challenge creative edge , got basics down works issue having error displaying whem there no error displays when page loads , displays value when calculator used can please help?

<?php  $value1 = $_post['value1']; $symbol = $_post['operator']; $value2 = $_post['value2']; $nulr = "nulrl";  if($nulr === "nulrl"){ if($symbol === "+"){ $output = $value1 + $value2; } elseif($symbol === "-"){ $output = $value1 - $value2; } elseif($symbol === "/"){ $output = $value1 / $value2; } elseif($symbol === "*"){ $output = $value1 * $value2; } else{ $output = "error not perform operation"; }  } echo $output; ?> 

edit here html code

<!doctype html> <html lang="en"> <head> <title>the calculator</title> <meta charset="utf-8"> <link rel="stylesheet" href="styles.css"> </head> <body> <header> <h1>the goal</h1> <p>through studies of coding languages have come realize  every coding langauage no matter how different syntax can  handle user input , variables , produce , output. being said wanna make interactive calculator each coding language , advance on each 1 , see language can produce best  calculator!</p>  <main> <h2>php calculator</h2> <form method="post"> <input type="number" name="value1" value="value1" class="number-box"> <br> <select name="operator"> <option value="+">+</option> <option value="-">-</option>     <option value="*">*</option> <option value="/">/</option> </select> <br> <input type ="number" name="value2" value="value2" class="number-box"> <br> <input type ="submit" name="submit" class="submit-button"> </form> <?include("calculator.php")?>  <footer> <h3>comment box</h3> <form method="post" action="comment.php"> <input type="text" value="name" name="name"> <br> <textarea name="comment">comments</textarea> <input type="submit" name="submit" class="submit-button"> </form>  <?php echo file_get_contents("comments.txt"); ?> </footer>   </main> </header> 

edit: still have not recieved correct answers

the simplest way:

<?php    if(isset($_post['value1']){     //.......     else{         $output = '';         echo "error, not perform operation";    }  }  echo $output; } ?> 

Comments