php insert from form
Posted on 2014-04-22
If I'm inserting data into a database through php. Is there any way the users doesn't have to full out all the form fields?
Why can't I just assign to 0 so if it's left empty it will insert a 0. However when I do that I get no results when it tries to update data.
$rent = ($_POST["rent"]);
$food = $_POST["food"];
$gas = ($_POST["gas"]);
$clothes = $_POST["clothes"];
$supplies = $_POST["supplies"];
$queryUpdate = "update january set rent=$rent, food=$food, gas=$gas, clothes=$clothes, supplies=$supplies where customerid='$id'";
$result = mysqli_query($connection, $queryUpdate);
die("doesn't update " .
"(" . mysqli_connect_errno() . ")"