Recoger datos de un formulario.

From: Date: Sun, 17 Nov 2002 12:29:32 +0000
Subject: Recoger datos de un formulario.
Groups: php.general.es 
Request: Send a blank email to general-es+get-29386@lists.php.net to get a copy of this message
He desarrollado una página html con un formulario simple, al darle al botón enviar llamo a una página php donde quiero recoger los datos introducidos en el formulario y almacenarlos en una base de datos MySql. Tenía entendido que si el campo nombre del formulario en la página html inicial se llamaba "name", en la página php su valor se almacenaría en la variable "$name", pero esto no me resulta porque esta variable siempre está vacía. Os pongo el código del formulario y de la página php, para que hagáis el favor de indicarme como recojo los valores: <html> <head> <title>Lista de email</title> </head> <body> <form action = "joinnemail.php" method = "post"> <table> <tr><td> Name : </td> <td><input type = "text" name = "name"> </td></tr> <tr><td> Email : </td> <td><input type = "text" name = "email"> </td></tr> <tr><td> <input type = "submit" value = "join"></td> <td><input type = "reset" value = "clear"></td></tr> </table> </form> </body> </html> y la página joinnemail.php <html> <head> <title>Lista de email</title> </head> <body> <?php //make a connection $servidor = "localhost"; $usuario = "username"; $password = ""; $base_de_datos = "email"; $connection = @mysql_connect ($servidor,$usuario,$password); if(!$connection) { echo ('Imposible conectarse con MySQL,'); exit();} if(!@mysql_select_db($base_de_datos)) { echo ('Imposible conectarse con la BD'); exit();} //select our database email //$db = mysql_select_db("email" , $connection) //insert the values of our form into our database $sql_query = "INSERT INTO email VALUES (\"$name\",\"$email\")"; $results = mysql_query($sql_query); //display a thank you message and a link echo ("Thank you for subscribing to our newsletter<br>"); echo ("<a href = 'index.htm'>Back to index page</a>"); ?> </body> </html> Gracias de antemano. Saludos.

« previous php.general.es (#29386) next »