html del formulario:
Código:
El script PHP que recive los datos y los envía a mi base de mysql:<!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Formulario</title> <style type="text/css"> #formulario { background-color: #09C; height: auto; width: 400px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding: 10px; } form { font-family: "Arial Black", Gadget, sans-serif; color: #00F; } </style> </head> <body> <div id="formulario"> <form id="form1" name="form1" method="post" action="insertar.php"> <table width="400" border="0" cellspacing="0" cellpadding="0"> <tr> <td><label for="nombre">Nombre:</label></td> <td><input type="text" name="nombre" id="nombre" /></td> </tr> <tr> <td><label for="apellido">Apellidos:</label></td> <td><input type="text" name="apellido" id="apellido" /></td> </tr> <tr> <td><label for="grado">Grado:</label></td> <td><select name="grado" id="grado"> <option>Cuarto Bachillerato</option> <option>Quinto Bachillerato</option> </select></td> </tr> <tr> <td><label for="carrera">Carrera:</label></td> <td><select name="carrera" id="carrera"> <option>Computación</option> <option>Diseño</option> </select></td> </tr> <tr> <td><label for="seccion">Sección:</label></td> <td><select name="seccion" id="seccion"> <option>A</option> <option>B</option> </select></td> </tr> <tr> <td><label for="email">Email:</label></td> <td><input type="text" name="email" id="email" /></td> </tr> <tr> <td><label for="codigo">Código del Libro:</label></td> <td><input type="text" name="codigo" id="codigo" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="enviar" id="enviar" value="Enviar" /></td> </tr> </table> </form> </div> </body> </html>
Código:
<?php $nombre = $_POST['nombre']; $apellido = $_POST['apellido']; $grado = $_POST['grado']; $carrera = $_POST['carrera']; $seccion = $_POST['seccion']; $email = $_POST['email']; $codigo = $_POST['codigo']; $conexion = mysql_connect("localhost","manuel","mld100050500"); mysql_select_db("alumnos",$conexion); mysql_query("INSERT INTO datos(Nombre, Apellido, Grado, Carrera, Seccion, Email, Codigo) VALUES ('$nombre','$apellido','$grado','$carrera','$seccion','$email','$codigo')"); ?> <script type="text/javascript">