title: How to get value from input box and store it in php variable?
body: <p>I'm working on this website and I can't seem to get some things to work.</p>
  
  <p>I have 3 inputs in my html:</p>
  
  <pre><code>&lt;form action='' method='post'&gt;
      &lt;input id='counterName' name='counterName' type='text' value='nothing'&gt;&lt;/input&gt;
  &lt;/form&gt;
  
  &lt;form action='' method='post'&gt;
      &lt;input type='text' value='3' name='counterNum' class='counter'&gt;&lt;/input&gt;
  &lt;/form&gt;
  
  &lt;form action='' method='post'&gt;
      &lt;input type='submit' value='Save' name='save' id='save'&gt;&lt;/input&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I want to get the value of the first two (counterName and counterNum) and store it in 2 variables when I click on the Save button. So I did:</p>
  
  <pre><code>if(isset($_POST['save'])){
          $counterName = $_POST['counterName'];
          $counterNum = $_POST['counterNum'];
          $prefix = mysql_real_escape_string("`~");
  }
  </code></pre>
  
  <p>You will see where $prefix is used in a second.</p>
  
  <p>Next I want to take those three variables and save them to my MySql's database column by concatenating in the following format. "<code>~$counterName</code>~$counterNum". Here is how I did it:</p>
  
  <pre><code>mysql_query("UPDATE `users` SET `counter` = CONCAT (`counter`,'$prefix') WHERE `userID` = '$userID'");
  mysql_query("UPDATE `users` SET `counter` = CONCAT (`counter`,'$counterName') WHERE `userID` = '$userID'");
  mysql_query("UPDATE `users` SET `counter` = CONCAT (`counter`,'$prefix') WHERE `userID` = '$userID'");
  mysql_query("UPDATE `users` SET `counter` = CONCAT (`counter`,'$counterNum') WHERE `userID` = '$userID'");
  </code></pre>
  
  <p>My issue is that when I see what the column "counter" holds I see this: "<code>~</code>~" without the variables in between. What am I doing wrong? Btw the type of the column is VARCHAR.</p>
  
  <p>Thank you.</p>