Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/08/2011, 12:35
eybel
 
Fecha de Ingreso: marzo-2007
Mensajes: 782
Antigüedad: 17 años, 1 mes
Puntos: 16
No me hace INSERT INTO en este codigo

Este es mi codigo que estoy haciendo y hasta ahora el PHP me funciona bien pero voy a mi localhost server en mi pc y en mi MySQL no veo ningun dato ingresado del formulario, saben porque?? se suponge que el comando "INSERT INTO users..." me guardaria el username y el password codificado pero no hay datos ingresados, alguna idea de porque??

My tabla se llama "users" y el orden de las columnas es (password, username, firstname...

Ver //*************************** en el codigo

Código PHP:
<?php 

//require_once('configuration.php');

//Connect to the database
$dbcmysqli_connect('localhost','root','root','chic');

//See if the connection to the DB was succesful
if (!$dbc) {
    echo
'Can\'t connect to the DB server';
    exit();
}

//If submit is set it up, or "used/pressed" then continue
if (isset($_POST['submit'])) {

//Making sure that all the user-entered data is cleaned up from spaces or characters
$username mysqli_real_escape_string($dbctrim($_POST['username']));
$password1 mysqli_real_escape_string($dbctrim($_POST['password1']));
$password2 mysqli_real_escape_string($dbctrim($_POST['password2']));

//Making sure the fields are not empty and that password1 is equal password2
if (!empty($username) && !empty($password1) && !empty($password2) && ($password1 == $password2))

{  

//make sure nobody is registered using this username
$query "SELECT * FROM users WHERE username='$username'";

$data mysqli_query($dbc$query);

if (
mysqli_num_rows($data)==0) {
    
//*********************************The username is unique, so insert the data into the database
$query "INSERT INTO users (password, username) VALUES (SHA('$password1'), '$username', NOW())";

echo
'A esta altura el INSERT INTO ya tiene que haberse procesado';

//This would process the new query
mysqli_query($dbc$query);

//Confirm success with the user
echo'<p> Your new account has been successfully created. You\'re now ready to log in <a href="index.php">HERE</a></p>';

mysqli_close($dbc);

//exit the script
exit();

//Applys to third If on line 34
                                
} else {

//An account already exists for this username, so display an error message
        
echo'<p class="error">An account already exists for this username. Please use a different address</p>';

//Clear the $username variable so that the form field is cleared.
$username="";
                                       }

//Applys to second If on line 27
} else {
    
//One of more of the form fields are empty, so display an error message.    
        
echo '<p class="error"> You must enter all of the sign-up data, including the desired password twice</p>';
       }

//Close first If on line 18       
}

//Close msqli connection
mysqli_close($dbc);        

       

?>