Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/05/2006, 18:00
okram
Invitado
 
Mensajes: n/a
Puntos:
Para insertar datos en una BD debes usar sentencias php y no codigos javascript...

Una cosa que puedes hacer es esta:

Código PHP:
<?php
if(!isset($_GET['nombre']) || !isset($_GET['email'])) {
?>
    <script language="javascript" type="text/javascript">
alert('The pixel you selected is a winner pixel!! Please click OK to enter the contest!!\n Just fill the form with your Name and Email');
    var nombre = prompt("Please write your name:","Your Name");
    var email = prompt("Please write your email:","[email protected]");
    location.replace('?nombre=' + nombre + '&email=' + email);
    </script>
<?php
} else {
// AQUI INSERTAS LOS DATOS A TU BD

// PRIMERO DEBES REALIZAR LA CONEXION A LA BASE DE DATOS
mysql_connect('SERVIDOR','USUARIO','CONTRASEÑA') or die('error conectando a la bd');
mysql_select_db('NOMBRE_DE_LA_BD') or die('error seleccionando la bd');

$sql "INSERT INTO tabla (nombre, email) VALUES ('".$_GET['nombre']."','".$_GET['email']."')";
if(
mysql_query($sql)) {
echo 
'Your data has been registered!! Now you are in the contest.<br />Remember that you can try all times you want!!';
} else {
echo 
'no se insertaron los datos porque:<br />'.mysql_error();
}
}
?>