![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
17/10/2007, 09:35
|
| | Fecha de Ingreso: septiembre-2006 Ubicación: mex
Mensajes: 41
Antigüedad: 18 años, 4 meses Puntos: 0 | |
Re: Como guardar datos en MySql Este es un pequeñito programa en PHP que da de alta un registro en una tabla agenda. Prueba aver si te sirve, ten cuidado en la linea: mysql_connect() y en la de mysql_select_db.
<?PHP
echo '<form action="'.$_PHP_SELF.'" method="post">';
echo "Escribe la clave:";
echo '<input type="text" name ="clave" size="5" maxlength="5" ><br/>';
echo "Escribe el numbre:";
echo '<input type="text" name ="nombre" size="25" maxlength="25" >';
echo'<input type = "submit" value="guardar" name="guardar"> ';
echo '</form>';
if ($_POST['guardar']){
guardar();
}
function guardar(){
mysql_connect('localhost', 'root', 'admin');
mysql_select_db("nom_de_la_BDD");
$qry="INSERT INTO agenda(clave, nombre) VALUES ('".$_POST['clave']."','".$_POST['nombre']."')";
if (mysql_query($qry)){
echo "Datos Guardados";
}
}
?> |