title: update state in database when user clicks link php
body: <p>I am trying to make my php website update mysql database depending on which (one of two) link the user clicks, however, I either get both links in the database or just the same one. I am using an if statement since i am trying to differentiate between the links clicked.  </p>
  
  <p>I've tried using <code>$_GET['state']</code>, <code>$_REQUEST['state']</code>, rearranging my code, or using 2 if statements instead of 1 else if statement, but still no help. (<code>curr_stat</code> is my table), here is my code:</p>
  
  <pre><code>&lt;?php
  //if links are clicked, will write to database the status
  
  $connect_error= 'Sorry, we are experiencing connection problems.';
  $db_name = "database name";
  $connection = @mysql_connect("some host", "some username","password") or die($connect_error);
  $db3 = @mysql_select_db($db_name,$connection) or die($connect_error);
  
  //if statement
  
  $unlock = '&lt;a href="doorlock.php?state=1"&gt;UNLOCK &amp;nbsp;&lt;/a&gt;&amp;nbsp;';
  echo $unlock;
  
  $lock = '&lt;a href="doorlock.php?state=0"&gt;LOCK&lt;/a&gt;';
  echo $lock;
  
  if ($_GET['state'] == 1){
      $one = 1;
      mysql_query("INSERT INTO curr_stat(status) VALUES($one)");
  }
  elseif ($_GET['state'] == 0){
      $zero = 0;
      mysql_query("INSERT INTO curr_stat(status) VALUES($zero)");
  }
  ?&gt;
  </code></pre>