title: default value for $_POST[];
body: <p>I have a problem with default value for $_POST[];
  So i have a html form with textboxes and the informations is sent to a php script. The php script has a sql query that is being sent to my database. But if my textbox in html form is empty the query doesnt have a value. So i want to set my post to a default value 0 so it returns a value atleast.</p>
  
  <p>So here is an example of html form (This is not my actuall script. Just an example.</p>
  
  <pre><code>&lt;form action="testscript.php" method="POST"&gt;
      &lt;input type="id" name="ID"/&gt;
      &lt;input type="text" name="test"/&gt;
      &lt;input type="submit" value="Send"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Ok so this script will send both id and test textboxes will always have a number value. And it sends the information to testscript.php</p>
  
  <p>Here is testscript.php example</p>
  
  <pre><code>    $conn = mysqli_connect('host', 'dbuser', 'dbpass', 'dbname');
      $id = $_POST['id'];
      $test = $_POST['test'];
      $sql = "INSERT INTO test_table (id, test) VALUES ($id, $test)";
  
      if (mysqli_query($conn, $query)) {
          echo "Success";
      } else {
          echo "Failed" . mysqli_error($conn);
      }
  </code></pre>
  
  <p>Alright so now if i submit my html form to php script without inserting any text to the textboxes the query will look like this</p>
  
  <pre><code>INSERT INTO test_table (id, test) VALUES ( , )
  </code></pre>
  
  <p>But the query should be like this</p>
  
  <pre><code>INSERT INTO test_table (id, test) VALUES (0, 0)
  </code></pre>
  
  <p>So. I know i can use value attribute in the html tag but then the value will be visible in the textbox and i dont want that.</p>
  
  <p>And i know i can do an if statment to make a default value like this</p>
  
  <pre><code>if (isset($_POST['test'])) {
      $test = $_POST['test'];
  } else {
      $test = 0;
  }
  </code></pre>
  
  <p>But now the problem is that i would have to do that if statment for every textbox and my html form have more than 100 textboxes. So i dont want to make an if statment for every textbox because then my script will be way to big and it will take hours.</p>
  
  <p>So is there any way to set a default value for all the textboxes without using if statment in php or value attribute in html form?</p>