title: Quadratic equation solver in php
body: <p>I tried to make a quadratic equation solver in php:</p>
  
  <p><strong>index.html:</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;form action="findx.php" method="post"&gt;
              Find solution for ax^2 + bx + c&lt;br&gt;
              a: &lt;input type="text" name="a"&gt;&lt;br&gt;
              b: &lt;input type="text" name="b"&gt;&lt;br&gt;
              c: &lt;input type="text" name="c"&gt;&lt;br&gt;
              &lt;input type="submit" value="Find x!"&gt;
          &lt;/form&gt;   
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>findx.php:</strong></p>
  
  <pre><code>&lt;?php
      if(isset($_POST['a'])){ $a = $_POST['a']; } 
      if(isset($_POST['b'])){ $b = $_POST['b']; } 
      if(isset($_POST['c'])){ $c = $_POST['c']; }
  
      $d = $b*$b - 4*$a*$c;
      echo $d;
  
      if($d &lt; 0) {
          echo "The equation has no real solutions!";
      } elseif($d = 0) {
          echo "x = ";
          echo (-$b / 2*$a);
      } else  {
          echo "x1 = ";
          echo ((-$b + sqrt($d)) / (2*$a));
          echo "&lt;br&gt;";
          echo "x2 = ";
          echo ((-$b - sqrt($d)) / (2*$a));
      }
  ?&gt;
  </code></pre>
  
  <p>the problem is that it's returning wrong answers (d is right,x1 and x2 are not) seems like sqrt() is returning zero or maybe something else.</p>