Este codigo ademas tiene un script, para que aparesca una ventana cuando un campo no este escrito, si la solucion implica borrarlo, no hay problema.
saludos
Código :
<?php
$link = mysql_connect('localhost', xxxx_aaaaa', '123456') or die('Could not connect: ' . mysql_error());
$db_selected = mysql_select_db('xxxx_contacto', $link) or die ('Error while connecting to database: ' . mysql_error());
$opt=$HTTP_GET_VARS["opt"];
if ($opt==1)
{
$nombre=$HTTP_GET_VARS["nombre"];
$apellido=$HTTP_GET_VARS["apellido"];
$telefono=$HTTP_GET_VARS["telefono"];
$sql="insert into 'demo2' (nombre,apellido,telefono) values ('".$nombre."' ,'".$apellido."' ,'".$telefono."')";
$res=mysql_query($sql,$bd) or die (msql_error($dbi)."<br>Error.<br>"
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Formulario</title>
</head>
<script language="javascript">
function verifica()
{
if (f.nombre.value="")
{
alert("Por favor ingrese su nombre");
return;
}
f.opt.value="1";
f.enviar();
}
</script>
<body>
<form name="f">
<input type="hidden" name="opt" value="1"/>
<table width="23%" border="0">
<tr>
<td width="17%">Nombre</td>
<td width="83%"><label>
<input type="text" name="nombre" id="nombre"/>
</label></td>
</tr>
<tr>
<td>Apellido</td>
<td><label>
<input type="text" name="apellido" id="apellido" />
</label></td>
</tr>
<tr>
<td>Telefono</td>
<td><label>
<input type="text" name="telefono" id="telefono" />
</label></td>
</tr>
<tr>
<td><label>
<input type="submit" name="enviar" id="enviar" value="Enviar" onclick=verifica()/>
</label></td>
<td><label>
<input name="restablecer" type="reset" id="restablecer" value="Restablecer" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
