![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
26/02/2008, 14:31
|
![Avatar de Hony](http://static.forosdelweb.com/customavatars/avatar212279_1.gif) | | | Fecha de Ingreso: enero-2008
Mensajes: 21
Antigüedad: 17 años Puntos: 0 | |
Re: Insertar registros en Base de Datos Este es el script de mi archivo "insertar.php" donde tengo el formulario:
--------------------------------------------------------------------------------------------
<?
$opc=$_GET[opc];
?>
<html
<head>
<title>Ejemplo de PHP</title>
</head>
<body>
<form action="procesar.php">
<TABLE>
<TR>
<TD>Nombre:</TD>
<TD><INPUT TYPE="text" NAME="nombre" SIZE="20" MAXLENGTH="30"></TD>
</TR>
<TR>
<TD>Apellido:</TD>
<TD><INPUT TYPE="text" NAME="apellido" SIZE="20" MAXLENGTH="30"></TD>
</TR>
</TABLE>
<input type="submit">
</form>
</body>
</html>
-----------------------------------------------------------------------------------------------------
Este es el script de mi archivo "procesar.php"
----------------------------------------------------------
<?
function conectar(){
$link = mysql_connect('localhost', 'root', '25187168');
$db_selected = mysql_select_db("prueba", $link);
$nombre=$_GET['nombre'];
$apellido=$_GET['apellido'];
$sql = "insert into prueba (nombre,apellido) values ('$nombre','$apellido')";
$result = mysql_query($sql) or die( "error en $sql, " . mysql_error() );
$selc = "select * from persona";
$re = mysql_db_query("prueba",$selc);
while($row = mysql_fetch_array($re))
{echo('<tr> <td> %s</td> <td> %s </td> </tr>'.$row["nombre"].$row["apellido"];}
mysql_free_result($re);
}
?> |