Ver Mensaje Individual
  #13 (permalink)  
Antiguo 03/12/2007, 08:08
Avatar de rogertm
rogertm
Mod->Cuba
 
Fecha de Ingreso: julio-2005
Ubicación: /home/Cuba/Habana/rogertm/
Mensajes: 2.922
Antigüedad: 18 años, 9 meses
Puntos: 638
Re: ayuda con base de datos en php

hola colocoloman, no chateo , prefiero postear, lo que tienes que hacer (elevado a la N), jajaja, es tener tu conexion:
Código PHP:
// este es el archivo conect.php
$host "localhost";
$database "tubasededatos";
$user "root";
$password "******";
$conect mysql_connect($host$user$password); 
y luego en otro archivo tu script:
Código PHP:
 <?php
include ("conect.php"); // conexion a la base de datos
$conect mysql_connect($host$user$password);
mysql_select_db($database$db_link);
if (isset(
$_POST['enviar']) && $_POST['enviar'] == 'Enviar'){
        if (!empty(
$_POST['nombre']) && $_POST['telefono']){ 
            
$nombre == $_POST['nombre'];
            
$telefono == $_POST['telefono'];
        }
mysql_select_db($database$conect);
$sql mysql_query("INSERT INTO clientes (nombre, telefono) VALUES ('$nombre', '$telefono')",
    
$conect) or die(mysql_error());
echo 
"Se ingresaron los registros correctamente";
}
else {
echo 
"Debe llenar todos los campos del formulario";
}
?> 
<!-- junto con el formulario
     todo en el mismo archivo -->
 <form name="clientes" method="post" action="$_SERVER['PHP_SELF']">
    Nombre<br><input type="text" name="nombre"><br>
    Telefono<br><input type="text" name="telefono"><br>
    <input type="submit" name="enviar" value="Enviar">
</form>
AHORA: en tu tabla tienes los campos telefono y nombre verdad???
en el include() tienes que tener la ruta correcta de tu archivo de conexion, ok?

PD: ve leyendote esto: http://www.php.net/manual/es/

seguiremos informando
__________________
Friki y Blogger por Cuenta Propia:213
Twenty'em: Theming is Prose