title: PHP post hexadecimal values from option and store to mysql in string format
body: <p>I need to store a hexadecimal value (values posted from my <code>&lt;options&gt;</code>) to my mysql database without transforming it (stay as is in string form) so that I can compare that value to my select options in string form. I've tried a lot of things, like base_convert(), (string), hex2bin(), but unfortunately. I don't know how to do this.</p>
  
  <p><img src="https://i.stack.imgur.com/vKbhF.png" alt="enter image description here"></p>
  
  <p>The image shows the stored value.</p>
  
  <p>This is what I have done so far.</p>
  
  <p>login.php:</p>
  
  <pre><code>$q = mysqli_query($con, "select * from users where email = '$email' and password = '$password'");
  if (mysqli_num_rows($q) == 0)
  {
  $response['message'] = "Account not found.";
  }
  else
  {
  $_SESSION['user_currency'] = (string)$f['user_currency'];
  }
  </code></pre>
  
  <p>dasboard.php:</p>
  
  <pre><code>&lt;form id="form_setting_currency"&gt;
  &lt;select name="select_currency_symbol" class="form-control"&gt;
   &lt;option value="&amp;#x24;" &lt;?php echo $_SESSION['user_currency'] == "&amp;#x24;" ? "selected" : ""; ?&gt; &gt;&amp;#x24; Dollar&lt;/option&gt;
   &lt;option value="&amp;#xa2;" &lt;?php echo $_SESSION['user_currency'] == "&amp;#xa2;" ? "selected" : ""; ?&gt; &gt;&amp;#xa2; Cent&lt;/option&gt;
   &lt;option value="&amp;#xa3;" &lt;?php echo $_SESSION['user_currency'] == "&amp;#xa3;" ? "selected" : ""; ?&gt; &gt;&amp;#xa3; Pound Sterling&lt;/option&gt;
  &lt;option value="&amp;#xa5;" &lt;?php echo $_SESSION['user_currency'] == "&amp;#xa5;" ? "selected" : ""; ?&gt; &gt;&amp;#xa5; Yen&lt;/option&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>SUBMIT_change_currency.php</p>
  
  <pre><code>&lt;?php
  include "includes/connection.php";
  require_once("includes/encryption.class.php");
  
  $response['success'] = false;
  $response['message'] = "An error has occurred.";
  
  if(isset($_POST['select_currency_symbol']) &amp;&amp;     trim($_POST['select_currency_symbol']) != "")
  {
  
  $currencyIcon = mysqli_real_escape_string($con,$_POST['select_currency_symbol']);
  // $currencyIcon = mysqli_real_escape_string($con,hex2bin($_POST['select_currency_symbol']));
  // $currencyIcon = mysqli_real_escape_string($con,(string)$_POST['select_currency_symbol']);
  
  $query ="UPDATE users SET user_currency = '$currencyIcon' WHERE user_id =   $_SESSION[user_id]";
  mysqli_query($con,$query);
  
  if(mysqli_affected_rows($con)&gt;0)
  {
      $response['success'] = true;
      $response['message'] = "Successfully changed currency symbol.";
      $_SESSION['user_currency'] = (string)$currencyIcon;
  }
  else
  {
      $response['message'] = "You have not made changes.";
  }
  }
  die(json_encode($response));
  ?&gt;      `
  </code></pre>