Ver Mensaje Individual
  #15 (permalink)  
Antiguo 22/04/2011, 23:07
JenderxD
 
Fecha de Ingreso: abril-2011
Mensajes: 52
Antigüedad: 13 años
Puntos: 0
Respuesta: Error al Enviar Formulario A Base de Datos

Ya resolvi el Problema amigos Gracias a Todos Por Su Gran Ayuda.. Aca dejo la forma como lo resolvi con el Codigo Espero que a Alguin le Sirva de Algo :D... Ahora Buscare Informacion Sobre Iniciar Secciones.!

Código PHP:
<html>
    <head> 
       
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
        <title> INGRESAR DATOS CLIENTE</title>
        <LINK REL="stylesheet" type="text/css" href="estilo.css" media="all" <div align="center"> <img src="r11.png" width="340" height="200" border="2"  >
        <body style="color:#000000;background-color:#ffe08f;" >

        <script LANGUAGE="JAVASCRIPT">
            function verifica(){
     //validar el codigo
    if (document.funcion.codigo.value==0)
    {
       alert("Debes Ingresar el Codigo Del cliente")
       document.funcion.codigo.focus()
       return 0;
    }
     //validar nombre
    if (document.funcion.nombre.value==0)
    {
       alert("Debes Ingresar Nombre del cliente")
       document.funcion.nombre.focus()
       return 0;
    }
    //validar Direccion
    if (document.funcion.direccion.value==0)
    {
       alert("Debes Ingresar La Direccion Del Cliente")
       document.funcion.direccion.focus()
       return 0;
    }

    //validar Telefono
    if (document.funcion.telefono.value==0)
    {
       alert("Debes Ingresar El Telefono del Cliente")
       document.funcion.telefono.focus()
       return 0;
    }

    //validar Rif
    if (document.funcion.rif.value==0)
    {
       alert("Debe Introducir El Rif Del Cliente.")
       document.funcion.rif.focus()
       return 0;
    }

    //el formulario se envia
    alert("Muchas gracias por enviar el formulario");
    document.funcion.submit();
    document.funcion.opt.value=1;
}



        </script>
    </head>

    <body>



        <body>
        
           
            <center><h1>INGRESO DE DATOS CLIENTE</h1>
        <form method="POST" name="funcion" ACTION="procesar_cliente_formulario.php"
              onSubmit="return verifica();">
        
        <H3>DATOS PERSONALES</H3>
        <H4>CODIGO DEL CLIENTE:</H4>
        <input type="text" name="codigo" value=" " size="20"><br>
        <FONT COLOR="#FF0000">&nbsp;*CAMPO OBLIGATORIO &nbsp;</FONT><br>
        <H4>NOMBRE COMPLETO:</H4>
        <input type="text" name="nombre" value=" " size="20"><br>
        <FONT COLOR="#FF0000">&nbsp;*CAMPO OBLIGATORIO &nbsp;</FONT><br>
        <H4>DIRECCION DEL CLIENTE:</H4>
        <input type="text" name="direccion" value=" " size="20"><br>
        <FONT COLOR="#FF0000">&nbsp;*CAMPO OBLIGATORIO &nbsp;</FONT><br>
        <H4>TELEFONO DEL CLIENTE:</H4>
        <input type="text" name="telefono" value=" " size="20"><br>
        <FONT COLOR="#FF0000">&nbsp;*CAMPO OBLIGATORIO &nbsp;</FONT><br>
        <h4>RIF</h4>
        <input type ="text" name="rif" value=" " size="20"><br>
        <FONT COLOR="#FF0000">&nbsp;*CAMPO OBLIGATORIO &nbsp;</FONT><br>

        </form>
        </center>
        <center>
        <br>
        <BR>
        <tr>
            <td colspan="2">
                <p align="center"><input type="button" value="Enviar Datos" name="b3" onclick="verifica()">
                <p align="center"><input type="reset" name="borrar" value ="Borrar">
            </td>
        </tr>        
          
       </center>           
    </head>
    
    <body>

<?php

        $conexion
=mysql_connect("localhost","root","")
                        or die (
"error");

         
mysql_select_db("repuestos",$conexion);

       
//Conectar a la base de datos (bd).
         
$consulta  ="SELECT * FROM `cliente`";
     
$resultado mysql_query($consulta $conexion);


        
?>
        </body>
</html>

y el Otro Php dodne guarda informacion enviada..!

Código PHP:
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>RESULTADOS DEL FORMULARIO</title>
        <link rel="stylesheet" type ="text/css" href="estilo.css">
    </head>
    <body>
        <h1>RESULTADOS DEL FORMULARIO</h1>
        <?php
                $conexion 
mysql_connect("localhost","root","")
                        or die (
"error");

                
$seleccionar_bd mysql_select_db("repuestos"$conexion);

                if (!
$seleccionar_bd)
                    {
                    die(
"Fallo la selección de la Base de Datos: " mysql_error());
                    }

                    
$codigo $_POST["codigo"];
                    
$nombre $_POST["nombre"];
                    
$direccion $_POST["direccion"];
                    
$telefono $_POST["telefono"];
                    
$rif $_POST["rif"];

                    
$insertar mysql_query("INSERT INTO cliente (codigo,nombre,direccion,telefono,rif) VALUES ('$codigo', '$nombre', '$direccion', '$telefono', '$rif')"$conexion);
                    if (!
$insertar)
                        {
                    die(
"Fallo en la insercion de registro en la Base de Datos: " mysql_error());
                        }
                        else
                        {
                            echo 
"datos ingresados Correctamente!!!"
                            
                            }
//4. Cerrar conexión a la Base de Datos
mysql_close($conexion);
        
?>
        <BR><BR><a href="ingresar_formulario_cliente.php">REGRESAR AL FORMULARIO</a>
    </body>
</html>