title: PHP: $_POST variables unexistant into functions
body: <p>I am bringing some info trough $_POST, but when I try to make use of this info into any function, console emerges an error about Undefined Variable (in this example, $ms_img brings an error, as well as $con -the connection query declared on conexionbbdd.php- and any othe variable inside functions.</p>
  
  <p>EDIT: Neither passing as arguments works, it emerges one error per argument as this:</p>
  
  <blockquote>
    <p>Warning: Missing argument 1 for checkCost(), called in C:\wamp\www...\actions\msg_newMessage.php on line 96 and defined in C:\wamp\www...\actions\msg_newMessage.php on line 17</p>
  </blockquote>
  
  <pre><code>function checkCost($con,$ms_img,$id){...}
  </code></pre>
  
  <p>CODE:</p>
  
  <pre><code>&lt;?php
      session_start();
      include("../conexionbbdd.php");
      include("../conexionapi.php");
  
      $id = $_SESSION['id'];   
      $inclass = $_SESSION['inclass'];   
  
  if($_SESSION['estado'] == 'activo'){
  
      $ms_content = $_POST['ms_content'];
      $ms_img = $_POST['ms_img'];
      $ms_prefix = $_POST['ms_prefix'];
      $ms_phone = $_POST['ms_phone'];
  
  
      function checkCost(){
              $totalCost = 0;
  
              if ($ms_img!=""){
                      $totalCost=2;
              }   
  
              else{
                      $totalCost=1;
              }
  
              $checkCredits=mysqli_query($con,"SELECT us_credits FROM ws_users WHERE us_id=$id");
  
          }
  
  
          function sendMessage(){
  
              //WHATEVER
          }
  
      if($inclass==='1'){       
          checkCost();        
      }
      else{
          sendMessage();        
      }
  
  }else{
  
  header('location:../login.php');
  
  }
  ?&gt;
  </code></pre>