I have a form that will register your name, surnames, etc. and I have a field that asks for a number, I already register well, now I would like it if the number field is empty that I insert something by default, example: 0.
In the form I get the value of the input like this:
<div class="form-group">
<label for="name">Número</label>
<input type="number" name="no" class="form-control" placeholder="23" value="<?php if(isset($_POST['no'])) echo $_POST['no']; else echo "0" ?>" />
</div>
PHP:
require_once("dbcontroller.php");
$db_handle = new DBController();
if(!empty($_POST['no'])){
$username = $_POST['no'];
}
if(empty($_POST['userName'])){
$username = '8787';
}
$query = "INSERT INTO tabla (.....,no_interior,...) VALUES
(...,'" . $username . "',,...)";
But I do not register anything in the bd.
Thank you.