I am not able to save my form data to the bank.
I have the following files:
functions.php
/**
* Cadastro de Notas
*/
function add() {
if (!empty($_POST['nota'])) {
$today =
date_create('now', new DateTimeZone('America/Sao_Paulo'));
$nota = $_POST['nota'];
$aluno = $_POST['nota'];
$nota['modified'] = $nota['created'] = $today->format("Y-m-d H:i:s");
save('notas', $nota);
header('location: index.php');
}
}
add.php
<?php
require_once('functions.php');
add();
index2();
?>
<?php include(HEADER_TEMPLATE); ?>
<h2>Cadastrar Nota</h2>
<form action="add.php" method="post">
<!-- area de campos do form -->
<hr />
<div class="row">
<div class="form-group col-md-7">
<label for="name">Aluno</label>
<select class="form-control">
<?php if ($alunos) : ?>
<?php foreach ($alunos as $aluno) : ?>
<option value="<?php echo $aluno['AlunoID']; ?>" name="nota['AlunoID']"><?php echo $aluno['AlunoNome']; ?></option>
<?php endforeach; ?>
<?php else : ?>
<option>SEM RESULTADOS</option>
<?php endif; ?>
</select>
</div>
<div class="form-group col-md-7">
<label for="name">Materia</label>
<input type="text" class="form-control" name="nota['MateriaID']">
</div>
<div class="form-group col-md-7">
<label for="name">Nota</label>
<input type="text" class="form-control" name="nota['Nota']">
</div>
</div>
<div class="row">
<div class="form-group col-md-2">
<label for="campo3">Data de Cadastro</label>
<input type="text" class="form-control" name="nota['created']" disabled>
</div>
</div>
<div id="actions" class="row">
<div class="col-md-12">
<button type="submit" class="btn btn-primary">Cadastrar</button>
<a href="index.php" class="btn btn-default">Cancelar</a>
</div>
</div>
</form>
<?php include(FOOTER_TEMPLATE); ?>
What can it be?
Any help will be welcome.
Thank you for your attention.