0
$query = "INSERT INTO
" . $this->table_name . "
(data, sexo)
VALUES
(:data,:sexo)";
$stmt->bindValue(':data', $_REQUEST['data']);
$stmt->bindValue(':sexo', $_REQUEST['sexo']);
is making a mistake: Undefined index: sexo
.
the field sexo
is a radio button
and I didn’t select it before saving it in the bank.
if I select the field sexo
, data is saved normally in the database, why?
wanted to save even if the field is selected or not...
Well, the error is clear and you seemed to understand the reason. You’re trying to get information that doesn’t exist, so Undefined. Try to check if the field exists with a
if(isset($REQUEST_['campo']))
before inserting, if it does not exist, you make a decision, such as saving the field as null or 0, depending on how the column is in the database. Read more about isset()– user28595