Hi there,
I am new in PHP universe and now i have some mistakes in my code:
First code:
formulario.php ( the simple form to input data)
<!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" lang="pt-br">
<head>
<meta name="author" content="Marcelo Torres" />
<meta http-equiv="content-type" content="text/html; charset=iso-utf-8" />
<title>Formulário de contato em PHP</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<form action="formulario.php" method="post" >
<fieldset style="width: 50%; height: 50%;">
<legend>Ficha de Inscrição</legend>
<small>*Atenção: É obrigatório o preenchimento de todos os campos do formulário para validar a inscrição.</small><br />
<?
include_once "cadastoo.php";
?>
<label for="nome">Nome:</label>
<input id="nome" name="nome" size="31" type="text" /><br />
<label for="assunto">CPF:</label>
<input id="cpf" maxlength="11" name="cpf" size="11" type="text" /><br />
<label for="email">Email:</label>
<input id="email" name="email" size="31" type="text" /><br />
<label for="nome">Telefone:</label>
<input name="telefone" id="telefone" type="text" size="10" /><br />
<label for="nome">Matricula:</label>
<input id="matricula" name="matricula" size="8" type="text" /><br />
<label for="nome">Evento:</label>
<input id="evento" name="evento" type="text" size="31" /><br />
<label for="nome">Horário:</label>
<input name="horario" id="horario" type="text" size="10" /><br />
<input name="enviar" type="submit" value="Enviar inscrição" class="botao"/>
<input name="cancelar" type="reset" value="Limpar" class="botao"/>
</fieldset>
</form>
</body>
</html>
config.php (the settings of my database).
<?
$hostname= 'localhost'; // seu servidor
$usuario= 'root'; // usuario de seu banco de dados
$senha= ''; // senha do usuário
$banco= 'BD_INTRA'; // Banco de dados que será utilizado
mysql_connect ( $hostname, $usuario, $senha)or die(“Não conseguiu conectar: “.mysql_error());
mysql_select_db($banco,$hostname) or die(mysql_error());
?>
cadastroo.php (here the code to record in my database)
<?
if(isset($_POST['enviar'])){
include_once 'config.php';
$nome = isset($_POST['nome'])?$_POST['nome']:null;
$cpf = isset($_POST['cpf'])?$_POST['cpf']:null;
$email = isset($_POST['email'])?$_POST['email']:null;
$evento = isset($_POST['evento'])?$_POST['evento']:null;
$telefone = isset($_POST['telefone'])?$_POST['telefone']:null;
$turno = isset($_POST['horario'])?$_POST['horario']:null;
$matricula= isset($_POST['matricula'])?$_POST['matricula']:null;
$query="INSERT INTO cadastro (nome,cpf,email,telefone,matricula,evento,turno) VALUES('$nome','$cpf','$email','$telefone','$matricula','$evento','$turno')";
$res = mysql_query($query) or die(mysql_error());
mysql_close();
echo "Você foi registado com sucesso!";
}
?>
I don't know why do not record in my database ? what is wrong?


