Hola a todos!
Bueno abro este post para ver si entre todos me podeis ayudar a aclarar algunas dudas que tengo sobre mi trabajo.
Tengo creada un BD que consta de 7 tablas:
Cliente
invitado
registrado
alquilar
pelicula
genero
repartidor
En los clientes lo he separado en una jerarquia para distinguir de los registrados y los no registrados.
Alquilar es la relacion entre cliente y pelicula(con los atributos: id_cliente,id_pelicula,fecha_alquiler,id_repartidor,hora_alquiler..)
Para que el repartidor sepa que pelicula tiene que llevar a que cliente en que hora.
Para insertar los datos de los cliente que se registran tengo este codigo:
Conexion_BD.php
<?PHP
//Dades de la conexió
$servidor = 'localhost';
$usuario = 'root';
$clave = '';
$base_de_datos = 'films_collection';
function conectar() {
//Declaramos las variables como globales para poder hacer uso de ellas posteriormente
//desde fuera de este mismo script
global $servidor;
global $usuario;
global $clave;
global $base_de_datos;
global $conexion;
$conexion=mysql_connect($servidor,$usuario,$clave) or die (mysql_error ":No puedo conectarme a la base de datos"); //conexion a Mysql
mysql_select_db($base_de_datos); //una vez conectado se elije la base de datos
}
function desconectar() {
global $conexion;
mysql_close($conexion); //cerramos la conexion con la base de datos.
}
?>
Guardar_cliente.php
<?php
$usuario=$_POST['usuario'];
$contra_uno=$_POST['contra_uno'];
$contra_dos=$_POST['contra_dos'];
$nombre=$_POST['nombre'];
$apellidos=$_POST['apellidos'];
$fecha=$_POST['fecha'];
$sexo=$_POST['sexo'];
$via=$_POST['via'];
$email=$_POST['email'];
$direccion=$_POST['direccion'];
$telefono=$_POST['telefono'];
$mobil=$_POST['mobil'];
include("conexion_BD.php");
global $conexion;
global $servidor;
global $usuario;
global $clave;
global $base_de_datos;
conectar();
$sql="INSERT INTO registrado(usuario,contra_uno,contra_dos,nombre,apellidos,fecha,sexo,via,email,direccion,telefono,mobil) VALUES
('$usuario','$contra_uno','$contra_dos','$nombre','$apellidos','$fecha','$sexo','$via', '$email','$direccion', '$telefono', '$mobil')";
mysql_db_query($base_de_datos,$sql);
desconectar();
?>
registrarse.html
<html>
<head>
<title>||Films Colection|| Las mejores peliculas de todo Internet||</title>
<script type="text/javascript" src="jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery/jquery.slidertron-0.1.js"></script>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
@import "slidertron.css";
.Estilo2 {color: #FF9933}
a {color:orange}
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body link=#592114 vlink=#F7811D>
<!-- end #header-wrapper -->
<div id="logo">
<h1><a href="#">Films Collections</a></h1>
</div>
<div id="header">
<div id="menu">
<ul>
<li><a href="index.html" class="first">Inicio</a></li>
<li class="current_page_item"><a href="#">peliculas</a></li>
<li><a href="#">Foro</a></li>
<li><a href="#">Registrarse</a></li>
<li><a href="contacto.html">Contactar</a></li>
</ul>
</div>
<!-- end #menu -->
<div id="search">
<form method="get" action="">
<fieldset>
<input type="text" name="s" id="search-text" size="15" />
</fieldset>
</form>
</div>
<!-- end #search -->
</div>
<!-- end #header -->
<hr />
<!-- end #logo -->
<div id="page">
<div id="page-bgtop">
<div id="content">
<div class="post">
<h2 class="title"><a href="#" class="Estilo2">Formulario de registro </a></h2>
<div class="entry">
<!-- Formulario Usuario -->
<form action="guardar_cliente.php" method="post">
<fieldset>
<legend><B></font>DATOS USUARIO</B></legend>
<table width="280" border="0">
<tr>
<td width="124"><div align="right"><strong>Nombre Usuario:</strong></div></td>
<td width="146"><input type="text" name="usuario" /></td>
</tr>
<tr>
<td><div align="right"><strong>Contraseña:</strong></div></td>
<td><input type="password" name="contra_uno" />
</td>
</tr>
<tr>
<td><div align="right"><strong>Validar Contraseña:</strong></div></td>
<td><input type="password" name="contra_dos" />
</td>
</tr>
</table>
</fieldset>
<p> </p>
<fieldset>
<legend><b>DATOS PERSONALES</b></legend>
<table width="501" border="0">
<tr>
<td width="123"><div align="right"><strong>Nombre:</strong></div></td>
<td width="144">
<input type="text" name="nombre" />
</td>
<td width="66"> </td>
<td width="150"> </td>
</tr>
<tr>
<td><div align="right"><strong>Apellidos:</strong></div></td>
<td>
<input type="text" name="apellidos" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="right"><strong>Fecha de nacimiento:</strong></div></td>
<td>
<input type="text" name="fecha" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="right"><strong>Sexo:</strong></div></td>
<td><input type="radio" name="sexo" id="hombre">
Hombre <input type="radio" name="sexo" id="mujer">Mujer</td><br>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="right"><strong>Tipo de via: </strong></div></td>
<td><select name="via">
<option selected>--Elige una opción--</option>
<option>Calle</option>
<option>Avenida</option>
<option>Paseo</option>
<option>Plaza</option></select></td>
<td><div align="right"><strong>Dirección: </strong></div></td>
<td><input type="text" name="direccion" /></td>
</tr>
<tr>
<td><div align="right"><strong>Email:</strong></div></td>
<td><input type="text" name="email" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="right"><strong>Teléfono:</strong></div></td>
<td><input type="text" name="telefono" /></td>
<td><div align="right"><strong>Móbil:</strong></div></td>
<td><input type="text" name="mobil" /></td>
</tr>
</table>
</fieldset>
<p> </p>
<fieldset>
<legend><b>REGISTRARSE</b></legend>
<table width="131" border="0">
<tr>
<td width="54">
<input type="submit" name="enviar" value="Enviar" /> </td>
<td width="136"><input type="reset" name="reset" value="Restablecer" /> </td>
</tr>
</table>
</fieldset>
</form>
<p> </p>
</div>
</div>
</div>
<!-- end #content -->
<p> </p>
<div id="Layer1" style="position:absolute; width:200px; height:115px; z-index:1; top: 191px; left: 870px;"><img src="../../../Documents%20and%20Settings/Administrador/Escritorio/pelicula.jpg" width="300" height="607" /></div>
<div style="clear: both;"> </div>
</div>
<!-- end #page -->
</div>
<div id="footer">
<p>Copyright (c) 2010 www.filmscolection.com. All rights reserved. Design by Marta y Marina.</p>
</div>
<!-- end #footer -->
</body>
</html>
Y no consigo que al rellenar el formulario me envie los datos a la BD, a ver si me podeis decir que veis mal, o que cambiariais.
Un saludo y muchas gracias