0
<div class="modal fade" id="adcmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="exampleModalLabel">Adicione a nota dos seus alunos</h2>
</div>
<div class="modal-body">
<form method="post" action= "index.php">
<div class="form-group">
<label for="nome" class="control-label">Nome:</label>
<input type="text" class="form-control" name="nome">
</div>
<div class="form-group">
<label for="nota1" class="control-label">Nota1:</label>
<input type="text" class="form-control" id="nota1">
</div>
<div class="form-group">
<label for="nota2" class="control-label">Nota2:</label>
<input type="text" class="form-control" id="nota2">
</div>
<div class="form-group">
<label for="nota3" class="control-label">Nota3:</label>
<input type="text" class="form-control" id="nota3">
</div>
</form>
</div>
<div class="modal-footer">
<form><button type="button" class="btn btn-lg btn-danger" data-dismiss="modal">Fechar</button>
<input type="submit" name="addbtn" value="Adicionar" class="btn btn-lg btn-sample"></form>
</div>
</div>
</div>
</div>
<?php
include("config.php");
$con = mysqli_connect("localhost","root","","alunos");
$nome = $_POST['nome'];
if (isset($_GET['addbtn'])) {
$query = "INSERT INTO `aluno` (`id`, `nome`, `nota`, `nota2`, `nota3`) VALUES (NULL, $nome, '10', '20', '30')";
mysqli_query($con, $query);
}
?>
What’s wrong that’s not detecting the part $name = $_POST['name'];?
Notice: Undefined index: nome in C: xampp htdocs index.php on line 112
The POST only exists at the time you submit the form, so you also have to check if there is the $_POST['name']
– Thiago
if (isset($_GET['addbtn']) && isset($_POST['name'])) {
– Thiago
You place the Submit button outside the first <form></form> block which is the one containing the fields. Try to put inside it and you can remove the second <form></form block>.
– Marlon