HOLAS!!:..
Necesito un poco de ayuda....
Acabo de seguir un tuto, para crear un pequeño formulario en php y conectarlo a una base de datos...
Todo ok, pero el problema es que envia doble informacion a la base de datos.
Segun el tuto, esto no deberia pasar por que ya esta cubierto, pero igual ocurre.
Aqui les dejo el query, agradeceria ayuda...
Código PHP:
<?php
$db=mysql_connect("localhost","base","123123") or die ("No puedo conectarme a la base de datos");
mysql_select_db("datos");
$opt=$HTTP_GET_VARS["opt"];
if ($opt==1)
{$nombre=$HTTP_GET_VARS["nombre"];
$email=$HTTP_GET_VARS["email"];
$sql="insert into prospecto (nombre, email) values ('".$nombre."','".$email."')";
$res=mysql_query($sql,$db) or die (mysql_error());
}
?>
<!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>Documento sin título</title>
</head>
<script language="javascript">
function verifica()
{
if (f.email.value=="")
{alert ("pro favor ingrese su mail");
return;}
f.opt.value=1;
f.submit();
}
</script>
<body>
<form name="f">
<input type="hidden" name="opt">
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Nombre</td>
<td><label>
<input type="text" name="nombre" id="textfield" />
</label></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" id="textfield2" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="button" onclick=verifica() id="button" value="Enviar" /></td>
</tr>
</table>
</form>
</body>
</html>