Jump to content

Submitting Regstration Form


LiLaaron

Recommended Posts

Hi,

I have been building a registion form and i am near complete! but i am having a probelm with the data adding to the database correctly.

First my code:

[code]

            $sql ="SELECT (MAX(`user_id`) + 1) FROM bb_users";
            $row = mysql_query($sql,$connection) or die(mysql_error());

            $user_id = $row;

            $username = $_POST['username'];
            $email = $_POST['email'];
            $new_password = $_POST['new_password'];
            $website = $_POST['website'];
            $occupation = $_POST['occupation'];
            $location = $_POST['location'];
            $interests = $_POST['interests'];
            $yim = $_POST['yim'];
            $msn = $_POST['msn'];

            $results = mysql_query("INSERT INTO bb_users (user_id, username, user_password, user_email, user_website, user_occ, user_from, user_interests, user_yim, user_msnm)
                VALUES ('$user_id', '".$username."', '".MD5('$new_password')."', '$email', '$website', '$occupation', '$location', '$interests', '$yim', '$msn')", $connection) or die(mysql_error());

            $results1 = mysql_query("INSERT INTO bb_groups (group_name, group_description, group_single_user, group_moderator)
                VALUES ('', 'Personal User', 1, 0)", $connection) or die(mysql_error());

            $sql ="SELECT MAX(group_id) AS gtotal FROM bb_user_group";
            $grow = mysql_query($sql,$connection) or die(mysql_error());

            $group_id = $grow['gtotal'] + 1;

            $results2 = mysql_query("INSERT INTO bb_user_group  (user_id, group_id, user_pending)
                VALUES ($user_id, $group_id, 0)", $connection) or die(mysql_error());


            echo "Congrats, Registration is Complete.<BR><BR>You May Now Login!";

[/code]

This section here:

[code]
$sql ="SELECT (MAX(`user_id`) + 1) FROM bb_users";
            $row = mysql_query($sql,$connection) or die(mysql_error());

            $user_id = $row;
[/code]

Its surposed to add up all the rows in the table then add 1 too it, so then this become the user_id. But what i am getting is, you add it once and when you want to add another user, i get duplicate key.

The stranges thing ever tho,

[code]
$sql ="SELECT MAX(group_id) AS gtotal FROM bb_user_group";
            $grow = mysql_query($sql,$connection) or die(mysql_error());

            $group_id = $grow['gtotal'] + 1;
[/code]

This works fine! but when i try and do the same with the user_id i just get the same error, add 1, next is a duplicate key.

my registration is also for phpbb, my registration should be, you only register on the site, as the user wont have access to it, unless i give them permission, i got that working fine, but i just cant get this thing out of the way.

Another thing, when that 1 user is registered, on the forum whos online, it doesnt update with the newest member, it should do it automatically when the new user registers, yet its not a phpbb problem due to if you register there it works.

Really hope someone can help me finish this.
Thanks
Aaron
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.