I'm learning php through head first's php and mysql and I'm toying with the simplest of php scripts: data from a form is inserted into a mysql database. I have modified the example from chapter two to use it on my own form and db, but I haven't been able to make the db accept anything I write into the form.
Where's the error?
Here's the php script:
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Evaluaciones</title>
</head>
<body>
<h2>Evaluaciones</h2>
<?php
$nombre_apellido = $_POST['nombreYapellido'];
$dbc = mysqli_connect('localhost', 'root', 'password', 'evaluaciones')
or die('Error connecting to MySQL server.');
$query = "INSERT INTO `evaluaciones_cursos` (nombre_apellido) " .
"VALUES ('$nombre_apellido')";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
mysqli_close($dbc);
echo 'Gracias por llenar el formulario .<br />'.$nombre_apellido;
?>
</body>
</html>
And here's the html form
formbeta2.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1" />
<title>Evaluación de Curso</title>
<style type="text/css">
body {
background-color: #CC7722;
margin-left:20%;
margin-right:20%;
border:3px dotted gray;
padding: 10px 10px 10px 10px;
font-family:sans-serif;
}
.tabla img {
width:100%;
}
</style>
</head>
<body>
<form>
<img src='http://img690.imageshack.us/img690/4338/softrain2.jpg' width="408" height="123"border='0'/>
<h1>Evaluación</h1>
<p>Por favor, tome unos minutos para llenar esta evaluación. </p>
<p> </p>
<form action="script2.php" method="POST">
<p>
<!--h3>Info Personal</h3-->
<table>
<tr><td>Nombre y Apellido:</td> <td> <input type="text" name="nombreYapellido" value="" /> </td></tr>
</table>
<input type="submit" value="Enviar Evaluación"/>
</body>
</form>
</html>
On mysql I ran:
CREATE TABLE `evaluaciones_cursos` (
`nombre_apellido` VARCHAR(60)
)
Yet the info isn't showing on phpmyadmin. Why?