Foros del Web » Programando para Internet » PHP »

Problema con la base de datos

Estas en el tema de Problema con la base de datos en el foro de PHP en Foros del Web. No sube los registros en la base de datos no encuentro el error si alguien me puede ayudar Código PHP: <?php include( 'config.php' ); ?> ...
  #1 (permalink)  
Antiguo 04/11/2015, 11:52
 
Fecha de Ingreso: octubre-2015
Mensajes: 10
Antigüedad: 8 años, 6 meses
Puntos: 0
Problema con la base de datos

No sube los registros en la base de datos no encuentro el error si alguien me puede ayudar


Código PHP:
<?php
include('config.php');
?>
<!DOCTYPE html PUBLIC>
<html >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="<?php echo $design?>/style.css" rel="stylesheet" title="Style" />
        <title>Sign up</title>
    </head>
    <body>
        <div class="header">
            <a href="<?php echo $url_home?>"><img src="<?php echo $design?>/images/Bienvenidos.png" alt="Members Area" /></a>
        </div>
<?php
//We check if the form has been sent
if(isset($_POST['username'], $_POST['password'], $_POST['passverif'], $_POST['email'], $_POST['avatar']) and $_POST['username']!='')
{
    
//We remove slashes depending on the configuration
    
if(get_magic_quotes_gpc())
    {
        
$_POST['username'] = stripslashes($_POST['username']);
        
$_POST['password'] = stripslashes($_POST['password']);
        
$_POST['passverif'] = stripslashes($_POST['passverif']);
        
$_POST['email'] = stripslashes($_POST['email']);
    }
    
//We check if the two passwords are identical
    
if($_POST['password']==$_POST['passverif'])
    {
        
//We check if the password has 6 or more characters
        
if(strlen($_POST['password'])>=6)
        {
            
//We check if the email form is valid
            
if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email']))
            {
                
//We protect the variables
                
$username mysql_real_escape_string($_POST['username']);
                
$password mysql_real_escape_string($_POST['password']);
                
$email mysql_real_escape_string($_POST['email']);
                
//We check if there is no other user using the same username
                
$dn mysql_num_rows(mysql_query('select id from users where username="'.$username.'"'));
                if(
$dn==0)
                {
                    
//We count the number of users to give an ID to this one
                    
$dn2 mysql_num_rows(mysql_query('select id from users'));
                    
$id $dn2+1;
                    
//We save the informations to the databse
                    
if(mysql_query('insert into users(id, username, password, email, avatar, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$avatar.'", "'.time().'")'))
                    {
                        
//We dont display the form
                        
$form false;
?>
<div class="message">You have successfuly been signed up. You can log in.<br />
<a href="connexion.php">Log in</a></div>
<?php
                    
}
                    else
                    {
                        
//Otherwise, we say that an error occured
                        
$form true;
                        
$message 'An error occurred while signing up.';
                    }
                }
                else
                {
                    
//Otherwise, we say the username is not available
                    
$form true;
                    
$message 'The username you want to use is not available, please choose another one.';
                }
            }
            else
            {
                
//Otherwise, we say the email is not valid
                
$form true;
                
$message 'The email you entered is not valid.';
            }
        }
        else
        {
            
//Otherwise, we say the password is too short
            
$form true;
            
$message 'Your password must contain at least 6 characters.';
        }
    }
    else
    {
        
//Otherwise, we say the passwords are not identical
        
$form true;
        
$message 'The passwords you entered are not identical.';
    }
}
else
{
    
$form true;
}
if(
$form)
{
    
//We display a message if necessary
    
if(isset($message))
    {
        echo 
'<div class="message">'.$message.'</div>';
    }
    
//We display the form
?>
<div class="content">
    <form action="sign_up.php" method="post">
       
        <div class="center">
            <label for="username">Usuario</label><input type="text" name="username" value="<?php if(isset($_POST['username'])){echo htmlentities($_POST['username'], ENT_QUOTES'UTF-8');} ?>" /><br />
            <label for="password">Contraseña<span class="small">(6 characters min.)</span></label><input type="password" name="password" /><br />
            <label for="passverif">Confirmacion<span class="small"></span></label><input type="password" name="passverif" /><br />
            <label for="email">Email</label><input type="text" name="email" value="<?php if(isset($_POST['email'])){echo htmlentities($_POST['email'], ENT_QUOTES'UTF-8');} ?>" /><br />
            <input id="boton" type="submit" value="Entrar" />
        </div>
    </form>
</div>
<?php
}
?>
        
    </body>
</html>
en ese esta el problema este el es config.php
Código PHP:
<?php

session_start
();


mysql_connect("localhost""root""");
mysql_select_db('database');

$mail_webmaster '[email protected]';

$url_root 'http://www.example.com/';


$url_home 'index.php';

$design 'default';
?>
  #2 (permalink)  
Antiguo 04/11/2015, 17:09
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: Problema con la base de datos

Saludo
¿Y cuál es el mensaje que se obtiene?
¿Hay algún warning, o similar?

Revisa el log de errores, tal vez allí haya una pista.
De lo contrario, empieza a hacer un paso a paso
para ver hasta donde llega, y en donde se queda.
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com

Etiquetas: html, mysql, registro, select, sql, variable
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:50.