Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Ola,
Estou com um problema ao enviar os dados para o banco de dados.
Sempre que mando aparece a mensagem: Por favor preencha todos os campos.
Segui o codigo:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>planilha_de_notas</title>
</head>
<body>
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
if (isset($_POST['submit'])) {
$nota1 = $_POST['nota1'];
$materia = $_POST['materia'];
$nota2 = $_POST['nota2'];
$nota3 = $_POST['nota3'];
if (!empty($nota) && !empty($materia)) {
// Conecta ao banco de dados
$dbc = mysql_connect('localhost','root','') or die(mysql_error());
$sel = mysql_select_db('planilha_de_notas', $dbc);
// escrecve os dados na tabela
$query = "INSERT INTO da1.1.12 (nota1, materia, nota2, nota3) VALUES ('$nota1', '$materia', '$nota2', '$nota3')";
mysql_query($query) or die(mysql_error());
// sucesso da adição
echo '<p>Notas cadastradas com sucesso.</p>';
mysql_close($dbc);
}
else {
echo '<p class="error">Por favor preencha todos os campos.</p>';
}
}
?>
<form method="post" action= "<?php echo $_SERVER['PHP_SELF']; ?>">
<p>
<table cellspacing="0" cellpadding="0" border="1" align="center">
<col width="29" />
<col width="329" />
<col width="166" />
<col width="90" />
<tr>
<td colspan="4" width="614" align="center">PLANILHA DE NOTAS</td>
</tr>
<tr>
<td colspan="4">DOCTORADO EN ADMINISTRACIÓN: DA 1.1/12 – JULHO 2012</td>
</tr>
<tr>
<td colspan="4">ASIGNATURA: <select id="materia" name="materia" size="1" class="styled" />
<option value="">-Selecione-</option>
<option value="Contabilidade de Gestión">Contabilidade de Gestión</option>
<option value="Gestión de Personas y Relaciones Laborales">Gestión de Personas y Relaciones Laborales</option>
<option value="Teoria de los Modelos de Organización">Teoria de los Modelos de Organización</option>
</select>
</td>
</tr>
<tr>
<td colspan="4">PROFESOR: Gustavo Adolfo Valenzuela Ferreira </td>
</tr>
<tr>
<td width="29">Nº</td>
<td width="329">Apellidos y Nombres (completos)</td>
<td width="166">Cedula Identidad</td>
<td width="90">Nota Final</td>
</tr>
<tr>
<td width="29">1</td>
<td>RICARDO DE BONIS</td>
<td>14087</td>
<td><input type="text" id = "nota1" name = "nota1" size="10" /></td>
</tr>
<tr>
<td width="29">2</td>
<td>MARIA DE FÁTIMA B. SILVA</td>
<td>0856421421</td>
<td><input type="text" id = "nota2" name = "nota2" size="10" /></td>
</tr>
<tr>
<td width="29">3</td>
<td>ANISIA DARC DO N. BRAHIM</td>
<td>063849699</td>
<td><input type="text" id = "nota3" name = "nota3" size="10" /></td>
</tr>
</table>
<div align="center">
<input type="submit" name="submit" id="submit" value="Enviar"/>
</div>
</form>
</body>
</html>
alguem me ajuda D:
Carregando comentários...