title: Some help to use user input for my if else statement
body: <p>I am new to PHP and am trying to write a program that will generate a series of addition sums (involving two randomly generate two number from 0 to 100).  It then needs to let the user know if they have been successful or not and ask if they want to continue.  I have search through the site but there seems to be no similar answers to this.  Thank you in advance1</p>
  
  <p>This is what I have done so far;</p>
  
  <pre><code>  &lt;html&gt;
  &lt;head&gt;&lt;title&gt;Random addition&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;
  &lt;?php
  
  $first_number = rand(1,100);
  $second_number = rand(1,100);
  $direct_text = "What the sum of these two number; " . "  ";
  echo ($direct_text . $first_number . "". "+". "" .  $second_number) . "=". "&lt;br /&gt;";
  
  echo ("What do you think the answer is ?". "&lt;br /&gt;");
  ?&gt;
  
  &lt;?php
  //If form not submitted, display form.
  if (!isset($_POST['submit'])){
  ?&gt;
  &lt;form method="post" action="addition.php"&gt;
    &lt;p&gt;Answer:
      &lt;input type="text" name="answer"&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &lt;input type="submit" name="submit" value="Submit"&gt;
    &lt;/p&gt;
  &lt;/form&gt;
  
  &lt;?php
  //If form submitted, process input.
  }else{
  //Retrieve string from form submission.
  $answer = $_POST['answer'];
  }
  ?&gt;
  
  &lt;?php
  
  $sum_total = $first_number + $second_number;
  
  
  //$direct_text = "The two variables added together =  " . "&lt;br /&gt;";
  //print ($direct_text . $sum_total);
  
  if ($answer == $sum_total) {
      echo ("Well done, Your right!" . "The answer is " . $sum_total .  "&lt;br / &gt;");
  }
  else
  {
      echo ("Bad Luck.  " . " The answer is  " . $sum_total . "&lt;br / &gt;") ;
  }
   echo "Do you want to try again?" . "&lt;br / &gt;" .  "y or n (y for yes and n for no)"
  
  
  ?&gt;
  
  &lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have written an if else statement to use $answer variable but it brings up error that I haven't defined variable but I thought I had.  </p>