Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/12/2010, 13:12
brepon
 
Fecha de Ingreso: noviembre-2010
Mensajes: 21
Antigüedad: 13 años, 5 meses
Puntos: 0
no me funciona

Hola;haber si me podeis echar una mano,aquí os pongo este archivo
Por que no funciona?


<?php
//Conexion con la base de datos
function open_db_connection(){
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('No se pudo establecer conexion con el servidor de base de datos : ' . mysql_error());
}

$db_selected = mysql_select_db('registro', $link);
if (!$db_selected) {
die ('No se puede utilizar la base de datos test : ' . mysql_error());
}
}

function guardar_datos()
{
$nombre=$_POST['nombre'];
$email=$_POST['email'];
$apellido=$_POST['apellido'];
$sqlInsert='INSERT INTO cliente (clave, nombre, apellido, email) VALUES ("","'.$nombre.'","'.$apellido.'","'.$email.'") ';
mysql_query($sqlInsert);
}

if( isset($_POST['nombre']) && !empty($_POST['nombre']) && isset($_POST['apellido']) && !empty($_POST['apellido']) && isset($_POST['email']) && !empty($_POST['email']) )
{
open_db_connection();
guardar_datos();
}
?>
<html>
<head>
<title>registro</title>
</head>
<body>
<form name="cliente" method="post" action="">
<label>Tu nombre:</label>&nbsp;<input type="text" name="nombre" maxlength="100"><br/>
<label>Tu apellido:</label>&nbsp;<input type="text" name="apellido" maxlength="100"><br/>
<label>Tu E-Mail:</label>&nbsp;<input type="text" name="email" maxlength="150"><br/>
<input type="submit" value="Dar de alta">
</form>
</body>
</html>