Ver Mensaje Individual
  #7 (permalink)  
Antiguo 22/08/2008, 12:36
e_daniel316
 
Fecha de Ingreso: marzo-2008
Mensajes: 94
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Formularios con php y mysql

ola otra vez,
cambie unas cosas de mi formulario, le agrege un input "radio" y un "list",pero no se como declararlos. ademas con el cambio que hice ahora no pasa nada al presionar el boton ACEPTAR, aqui les dejo todo el codigo por cualquier cosa:

HTML:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registro de usuarios</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<label>Rut<br />
<input type="text" name="rut" id="rut" maxlength="10" />
</label>
</form>
<label>Nombre<br />
<input type="text" name="nom" id="nom" />
<br />
</label>
<form id="form2" name="form2" method="post" action="">
<label>Ape. Paterno<br />
<input type="text" name="a_pat" id="a_pat" />
</label>
</form>
<form id="form3" name="form3" method="post" action="">
<label>Ape. Materno <br />
<input type="text" name="a_mat" id="a_mat" />
</label>
<p><label>Sexo<br />
<input type="radio" name="radio" id="masc" value="masc" />
Masculino</label>&nbsp;</p>
<p>
<label>
<input type="radio" name="radio" id="fem" value="fem" />
Femenino</label>
</p>
</form>
<form id="form4" name="form4" method="post" action="">
<label>Pais <br />
<select name="list" id="list">
<option>Chile</option>
<option>Argentina</option>
<option>Bolivia</option>
<option>Brasil</option>
<option>Colombia</option>
</select>
</label>
<p>&nbsp; </p>
<button type="reset" name="Aceptar" value="Aceptar">Aceptar </button>
<button type="submit" name="Borrar" value="Borrar" >borrar</button>
</form>

PHP:

<?
$rut = $_POST["rut"];
$nombre = $_POST["nom"];
$pat = $_POST["a_pat"];
$mat = $_POST["a_mat"];

$error = '';
if(isset($_POST['enviado'])) {
$rut = $_POST['rut'];
$nombre = $_POST['nombre'];

/* Conexión, seleccionar base de datos*/
$db_link = mysql_connect("localhost", "root", "1234");
if (!$db_link) {
die("No se pudo conectar: " . mysql_error());
}
mysql_select_db("prueba") or die("No se pudo seleccionar la base de datos");

/* SQL query */

mysql_query("INSERT INTO usuarios (rut_us, nom_us) VALUES ('$rut' , '$nombre','$pat','$mat')") or die(mysql_error());
mysql_close($db_link);
}

/* Cerrar conexión */
mysql_close($db_link);
?>
</body>
</html>