error_reporting(E_ALL ^ E_NOTICE);
// iniciamos session
session_start ();
// archivos necesarios
require_once '../aute/config.php';
require_once '../aute/conexion.php';
require_once '../aute/esUsuario.php';
// obtengo puntero de conexion con la db
$dbConn = conectar();
/*// verificamos que no este conectado el usuario
if ( !empty( $_SESSION['email'] ) && !empty($_SESSION['user']) && !empty($_SESSION['pass']) ) {
$arrUsuario = esUsuario( $_SESSION['email'], $_SESSION['user'], $_SESSION['pass'], $dbConn );
}
// verificamos que sea un admin
if ( empty($arrUsuario) || $arrUsuario['tipo_usuario'] != 'cliente' ) {
header( 'Location: ../../index.php' );
die;
}*/
include 'autentificacion.php';
$cliente = "SELECT * FROM cliente WHERE id_cliente = '{$arrUsuario['id_cliente']}'";
$client = mysql_query ($cliente, $dbConn);
$cli = mysql_fetch_array ($client);
if ( !empty($_POST['submit']) ) {
if(isset($_POST['cif']) && !empty($_POST['cif'])) {
mysql_query("UPDATE cliente SET cif='{$_POST['cif']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
if(isset($_POST['nombre']) && !empty($_POST['nombre'])) {
mysql_query("UPDATE cliente SET nombre='{$_POST['nombre']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
if (isset($_POST['direccion']) && !empty($_POST['direccion'])){
mysql_query("UPDATE cliente SET direccion='{$_POST['direccion']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
if (isset($_POST['cp']) && !empty($_POST['cp'])){
mysql_query("UPDATE cliente SET cp='{$_POST['cp']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
if (isset($_POST['poblacion']) && !empty($_POST['poblacion'])){
mysql_query("UPDATE cliente SET poblacion='{$_POST['poblacion']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
if (isset($_POST['provincia']) && !empty($_POST['provincia'])){
mysql_query("UPDATE cliente SET provincia='{$_POST['provincia']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
if (isset($_POST['pais']) && !empty($_POST['pais'])){
mysql_query("UPDATE cliente SET pais='{$_POST['pais']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
if (isset($_POST['telefono']) && !empty($_POST['telefono'])){
function validarTelefono($numero)
{
$reg = "#^\d{9}$#";
return preg_match($reg, $numero);
}
//ejm:
if(validarTelefono($_POST['telefono']))
{
echo "telefono valido";
mysql_query("UPDATE cliente SET telefono='{$_POST['telefono']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
else
{
echo "Telefono invalido, no se han insertado los cambios.
";
$error= "No se ha modificado el telefono";
}
}
if (isset($_POST['fax']) && !empty($_POST['fax'])){
function validarfax($numero)
{
$reg = "#^\d{9}$#";
return preg_match($reg, $numero);
}
if(validarfax($_POST['fax']))
{
echo "Fax valido";
mysql_query("UPDATE cliente SET fax='{$_POST['fax']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
else
{
echo "Fax invalido, no se han insertado los cambios.
";
$error_f= "No se ha modificado el fax";
}
}
if (isset($_POST['web']) && !empty($_POST['web'])){
mysql_query("UPDATE cliente SET web='{$_POST['web']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn) or die ("error");
}
if (isset($_POST['notas']) && !empty($_POST['notas'])){
mysql_query("UPDATE cliente SET notas='{$_POST['notas']}' where id_cliente='{$arrUsuario['id_cliente']}'", $dbConn);
}
$my_error = mysql_error($dbConn);
if(!empty($my_error) || !empty($error) || !empty($error_f)) {
header("location: modificar_clientes.php?error=$my_error");
die;
} else {
//echo "Los datos han sido introducidos satisfactoriamente";
//echo 'inicio';
header("location: modificar_clientes.php?ok=true");
die;
}
}
$id=$_GET['id_cliente'];
// Ahora comprobaremos que todo ha ido correctamente
?>