im new to php and learning quite fast. i have a form which allows the user to update his/her security question and also requires the user to enter his/her reference number in order to go ahead with the change.

my code for the form is as follows:

```
    <form action="securityupdated.php" method="post">

<table width="80%" border="0">
  <tr>
    <td><label for="secret_question">Secret Question</label></td>
    <td><span id="spryselect1">
      <select name="secret_question" id="secret_question">
        <option selected="selected">Please Select Your Secret Question</option>
        <option id="secret_question" value="What Is Your Mothers Maiden Name?">What Is Your Mothers Maiden Name</option>
        <option id="secret_question" value="What Was The Name Of Your First Pet?">What Was The Name Of Your First Pet</option>
        <option id="secret_question" value="What Was Your First Car?">What Was Your First Car</option>
        <option id="secret_question" value="What Is Your Favourite Colour?">What Is Your Favourite Colour</option>
      </select>
      <span class="selectRequiredMsg">*</span></span></td>
  </tr>
  <tr>
    <td><br /><label for="secret_anwser">Your Anwser</label></td>
    <td><br /><span id="sprytextfield1">
      <input type="text" name="secret_anwser" id="secret_anwser" />
      <span class="textfieldRequiredMsg">*</span></span></td>
  </tr>
  <tr>
    <td><br /><label for="password">Your Reference</label>
</td>
    <td><br />
      <span id="sprytextfield2">
      <input type="text" name="ref" id="ref" />
      <span class="textfieldRequiredMsg">*</span></span></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><br /><input name="" type="submit" value="Update" /></td>
  </tr>
</table>
</form>

```

my php script is as follows:

```
    <?php 
$secret_question = mysql_real_escape_string($_REQUEST['secret_question']);
$secret_anwser = mysql_real_escape_string($_REQUEST['secret_anwser']);

$sql= "UPDATE public SET secret_question = '$secret_question', secret_anwser = '$secret_anwser' WHERE active = 'activated' AND ni = '". $_SESSION['ni']."'";

if (!mysql_query($sql))
  {
        die('Error: ' . mysql_error());
  }
  else 
  {
      echo '<hr /><h3 align="center">Security Question Has Been Updated</h3><hr />';

  }
?>

```

what i dont know is how to code it so that it can check if the ref entered by the user matches with my ref field in my database and if so then it should go ahead with the update and if not, it should ask the user to enter his password again?