Is not registering in db

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cronika
Forum Commoner
Posts: 27
Joined: Sun Jul 26, 2009 2:28 pm
Location: romania
Contact:

Is not registering in db

Post by cronika »

Code: Select all

 
<!-- Inregistrare  -->
<?php
// Conectare la db
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("agenda") or die(mysql_error());
//Formularul de inregistrare
if(isset($_POST['Submit']))
{
    if (!$_POST['nume'] | !$_POST['prenume'] | !$_POST['email']| !$_POST['parola'] | !$_POST['parola2'] )
        {
            die("Nu ai complectat toate campurile.");
        }
    //verificare daca exista acel email
    if (!get_magic_quotes_gpc()) 
        {
            $_POST['email'] = addslashes($_POST['email']);
        }
        $echeck = $_POST['email'];
        $check = mysql_query("SELECT email FROM user WHERE email = '$echeck'")or die(mysql_error());
        $check2 = mysql_num_rows($check);
    if ($check2 != 0) 
        {
            die('Adresa de email '.$_POST['email'].' exista deja.');
        }
    if ($_POST['parola'] != $_POST['parola2']) 
        {
            die('Parola introdusa nu este corecta. ');
        }
    //encriptez parola in md5
        $_POST['parola'] = md5($_POST['parola']);
    if (!get_magic_quotes_gpc())
        {
            $_POST['parola'] = addslashes($_POST['parola']);
            $_POST['nume'] = addslashes($_POST['nume']);
        }
    //introducem in database
    $inserare = "INSERT INTO user (nume, prenume, email, parola) VALUES ('".$_POST['nume']."', '".$_POST['prenume']."','".$_POST['email']."', '".$_POST['parola']."')";
    $adaugare = mysql_query($inserare);
}
?>
 
<form action="register.php" method="post">
<table border="0">
<tr><td>Nume:</td><td>
<input type="text" name="nume" maxlength="60">
</td></tr>
<tr><td>Prenume:</td><td>
<input type="text" name="prenume" maxlength="60">
</td></tr>
<tr><td>Email:</td><td>
<input type="text" name="email" maxlength="60">
</td></tr>
<tr><td>Parola:</td><td>
<input type="password" name="parola" maxlength="10">
</td></tr>
<tr><td>Confirmare Parola:</td><td>
<input type="password" name="parola2" maxlength="10">
</td></tr>
<tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> </table>
</form>
 
In browser i see the from but after i complete the form and send it, is not registering in db. Why?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Is not registering in db

Post by aceconcepts »

First of all i think you need to re-think the structure of your if statements and their scopes.

Secondly, try outputting a mysql error e.g.

Code: Select all

 
mysql_query($inserare) or die(mysql_error());
 
mysql_error() will output any errors if they exist.
Post Reply