Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/11/2010, 06:35
Ghosty
 
Fecha de Ingreso: junio-2008
Mensajes: 292
Antigüedad: 15 años, 10 meses
Puntos: 4
enviar form al cargar la pagina no funciona

Hola alguien me puede decir por que me envia a la bd los campos vacios...en teoria debe enviar el form al cargar la pagina pero no va..pero si cliko en el boton si aqui os dejo el codigo

Código PHP:
<?php
session_start
();
$variable1=$_SESSION['valormail'];
$variable2=$_SESSION['valorfuente'];
$variable3=$_SESSION['valorprevia'];
$variable4=$_SESSION['valorprecio'];

?>

<?php
        
// Si entramos es que todo se ha realizado correctamente

        
$link mysql_connect("localhost","_user","pass");
        
mysql_select_db("_bd",$link);

        
// Con esta sentencia SQL insertaremos los datos en la base de datos
        
mysql_query("INSERT INTO personalizadas (id_perso,mail,imagen,fuente,precio)
        VALUES ('','{$_POST['mail']}','{$_POST['previa']}','{$_POST['fuente']}','{$_POST['precio']}')"
,$link);

?>




 
<!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>
<script>
function enviar(){
  document.form.submit()
}
</script>
</head>

<body onload="enviar()">
<form action="formalta.php" method="post" name="form">
<input name="mail" type="text" value="<? echo $variable1 ?>" />
<input name="previa" type="text" value="<? echo $variable3 ?>" />
<input name="fuente" type="text" value="<? echo $variable2 ?>" />
<input name="precio" type="text" value="<? echo $variable4 ?>" />
 <input type="submit" name="submit" id="submit" value="Enviar" />
</form>

</body>
</html>

Última edición por Ghosty; 18/11/2010 a las 06:37 Razón: x