Me dice que hay un error de sintaxis:
Parse error: syntax error, unexpected $end in C:\wamp\www\guardar-cliente.php on line 105
He intentado poner comentarios al texto, a ver si ahora está más claro lo que quiero hacer. De todos modos, la parte de modificar el usuario está a medio hacer porque hasta que no funcione la de crear uno nuevo tampoco puedo modificarlo...
Ahí va el código:
Código HTML:
<div class="contenedor_contenidos">
<?php
//crea conexión con la bbdd
$conexion=mysql_connect("localhost","root","") or die("Problemas en la conexion");
mysql_select_db("clientes",$conexion) or die("Problemas en la seleccion de la base de datos");
if($_REQUEST[codigo]=="-")
{
//si no hemos definido el código, creamos cliente nuevo
//insertamos los parámetros del nuevo cliente en la tabla
mysql_query("insert into clientes(nombre,cif,direccion,codigo_postal,ciudad,telefono,fax,email,fecha_alta) values
(".$_REQUEST[nombre].",".$_REQUEST[cif].",".$_REQUEST[direccion].",".$_REQUEST[cp].",".$_REQUEST[ciudad].",".$_REQUEST[telefono].",".$_REQUEST[fax].",".$_REQUEST[email].",date(d/m/y))",
$conexion) or die("Problemas en el select".mysql_error());
mysql_close($conexion);
echo "El cliente ha sido añadido.";
}
else
{
//si definimos el código, modificamos cliente existente
//seleccionamos el cliente con el codigo correspondiente
$registros=mysql_query("select * from clientes where id=".$_REQUEST['codigo']."",$conexion) or die("Problemas en el select:".mysql_error());
if ($reg=mysql_fetch_array($registros))
{
//modificamos los diferentes campos de la tabla...como se haría el update??
//$registros=mysql_query("update clientes set cif=".$_REQUEST[mailnuevo]." where nombre=".$_REQUEST[nombre]."",$conexion) or die("Problemas en el select:".mysql_error());
echo "El mail fue modificado con exito";
}
?>
<div class="contenidos">
<br/><br/><br/>
<!--formulario para introducir los datos del cliente-->
<form style="margin-left:200px;" method="post" action="guardar-cliente.php">
Código: <input type="text" name="codigo" size="20" value="-"> <span style="margin-left:190px;" >Núm. albaranes: <input type="text" name="num_albaranes" size="20" value="0"/></span>
<br/><br/><br/>
<button type="submit">Nombre: </button> <input type="text" name="nombre" size="60"> <span style=" margin-left:10px;" >CIF: <input type="text" name="cif" size="20" /></span>
<br/><br/><br/>
Dirección: <input type="text" name="direccion" size="50" /><br/><br/>
C.P.: <input type="text" name="cp" size="10" /> <span style="margin-left:10px;">Ciudad: <input type="text" name="ciudad" size="30" /></span>
<br/><br/><br/>
Teléfono: <input type="text" name="telefono" size="20" /> <span style="margin-left:20px;">Fax: <input type="text" name="fax" size="20" /></span><br/><br/>
E-mail: <input type="text" name="email" size="55" />
<br/><br/> <span style="margin-left:420px;">Fecha de alta: <input type="text" name="fecha_alta" value="dd/mm/aa"/></span><br/><br/>
<span style="margin-left:280px;"><button type="submit"><br/>Guardar<br/><br/></button>
<button type="reset"><br/> Borrar <br/><br/></button></span>
</form></div>
Lo que preguntas del submit...tenía entendido que para que se ejecute el php es el botón que hay que utilizar. No es así?
Muchas gracias!!