Ver Mensaje Individual
  #3  
Antiguo 15-10-2012
ebanibaldo ebanibaldo is offline
Miembro
 
Registrado: feb 2010
Posts: 62
Reputación: 15
ebanibaldo Va por buen camino
Este codigo lo tengo en un archivo que tiene como nombre nuevo.php
Código PHP:
<script src="js/livevalidation_standalone.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="css/estilovali.css" />
<link type="text/css" rel="stylesheet" href="css/estilo.css" />
<?php

require('functions.php');
require (
'clases/conexion.class.php');
if(isset(
$_POST['submit'])){
    require(
'clases/cliente.class.php');
    
$clave htmlspecialchars(trim($_POST['clave']));
    
$nombre htmlspecialchars(trim($_POST['nombre']));
    
$autor htmlspecialchars(trim($_POST['autor']));
    
$editorial htmlspecialchars(trim($_POST['editorial']));
    
$paginas htmlspecialchars(trim($_POST['paginas']));
    
$cantidad htmlspecialchars(trim($_POST['cantidad']));
    
$ubicacion htmlspecialchars(trim($_POST['ubicacion']));
    
$fecha     htmlspecialchars(trim($_POST['fecha']));
    
$objCliente=new Cliente;
    if ( 
$objCliente->insertar(array($clave,$nombre,$autor,$editorial,$paginas,$cantidad,$ubicacion,$fecha)) == true){
        echo 
'Datos guardados';
    }else{
        echo 
'Se produjo un error. Intente nuevamente';
    } 
}else{
?>
  
<form id="frmClienteNuevo" name="frmClienteNuevo" method="post" action="nuevo.php" onSubmit="GrabarDatos(); return false">
  <p><label>clave<br/><input class="text" type="text" name="clave" id="clave" /></label></p>
  <p><label>nombre<br/><input class="text" type="text" name="nombre" id="nombre" /></label></p>
  <p><label>autor<br/><input class="text" type="text" name="autor" id="autor" /></label></p>
  <p><label>editorial<br/><input class="text" type="text" name="editorial" id="editorial" /></label></p>
  <p><label>paginas<br/><input class="text" type="text" name="paginas" id="paginas" /></label></p>
  <p><label>cantidad<br/><input class="text" type="text" name="cantidad" id="cantidad" /></label></p>
  <p><label>ubicacion<br/><input class="text" type="text" name="ubicacion" id="ubicacion" /></label></p>
  <p><label>Fecha<a onClick="show_calendar()" style="cursor: pointer;"><small>(calendario)</small></a><br />
    
    <input readonly="readonly" class="text" type="text" name="fecha" id="fecha" value="<?php echo date("Y-m-j")?>" />
    <div id="calendario" style="display:none;"> <?php calendar_html() ?> </div></label></p>  <p>
   
    <input type="submit" name="submit" id="button" value="Enviar"/>
    <label></label>
    <input type="button" class="cancelar" name="cancelar" id="cancelar" value="Cancelar" onClick="Cancelar()" />
    <input type="reset" value="borrar" />
  </p>
</form>
<?php
}
?>
y este otro codigo lo tengo en otro archivo donde realizo todas mis consultas de mysql y tiene como nombre cliente.class y que esta dentro de una carpeta llamada cliente.class.php

Código PHP:
<?php 
include_once("conexion.class.php");

class 
Cliente{
 
//constructor    
     
var $con;
     function 
Cliente(){
         
$this->con=new DBManager;
     }

    function 
insertar($campos){
        if(
$this->con->conectar()==true){
            
            return 
mysql_query("INSERT INTO libros (clave,nombre, autor, editorial, paginas, cantidad, ubicacion, fecha) VALUES ('".$campos[0]."', '".$campos[1]."','".$campos[2]."','".$campos[3]."','".$campos[4]."','".$campos[5]."','".$campos[6]."','".$campos[7]."')");
        }
    }
    
    function 
actualizar($campos,$id){
        if(
$this->con->conectar()==true){

            return 
mysql_query("UPDATE libros SET clave = '".$campos[0]."', nombre = '".$campos[1]."', autor = '".$campos[2]."', editorial = '".$campos[3]."', paginas = '".$campos[4]."', cantidad = '".$campos[5]."', ubicacion = '".$campos[6]."', fecha = '".$campos[7]."' WHERE id = ".$id);
        }
    }
    
    function 
mostrar_cliente($id){
        if(
$this->con->conectar()==true){
            return 
mysql_query("SELECT * FROM libros WHERE id=".$id);
        }
    }

    function 
mostrar_clientes(){
        if(
$this->con->conectar()==true){
            return 
mysql_query("SELECT * FROM libros ORDER BY id DESC");
        }
    }

    function 
eliminar($id){
        if(
$this->con->conectar()==true){
            return 
mysql_query("DELETE FROM libros WHERE id=".$id);
        }
    }
}
?>
El mensaje que describo al principio me sale que es en el archivo nuevo.php en las lineas donde mando a traer el valor de cada uno de los campos de el formulario que en este caso las lineas de nuevo.php son:
Código PHP:
$clave htmlspecialchars(trim($_POST['clave']));
    
$nombre htmlspecialchars(trim($_POST['nombre']));
    
$autor htmlspecialchars(trim($_POST['autor']));
    
$editorial htmlspecialchars(trim($_POST['editorial']));
    
$paginas htmlspecialchars(trim($_POST['paginas']));
    
$cantidad htmlspecialchars(trim($_POST['cantidad']));
    
$ubicacion htmlspecialchars(trim($_POST['ubicacion']));
    
$fecha     htmlspecialchars(trim($_POST['fecha'])); 
Gracias por su ayuda
Responder Con Cita