FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Help for sign_up form

 


jcvincent
Hello guys! i'm just wondering how can i create a singup form for my websit? i already know how to create a form, but i don't know how to give the user a primary key with a CHAR data type. Whats your suggestions about this?

I'm not going to use the (INT not null auto_increment) thing because I want the users to have a unique UserID using the data type CHAR. Please help.

Thank you so much!
Roald
It's very simple
Code:
CREATE TABLE 'members' (
'name' CHAR( 20 ) NOT NULL ,
PRIMARY KEY ( 'name' )
)
jcvincent
Roald wrote:
It's very simple
Code:
CREATE TABLE 'members' (
'name' CHAR( 20 ) NOT NULL ,
PRIMARY KEY ( 'name' )
)


This is not what I mean:

This is the table:

Create table TBL_User
(
userID char(10) not null primary key,
userName varchar(50) not null
);


Now, how can I give the user a userID automatically without having to encode its user ID? I'm using php 4, mysql 4, and an apache server.
SlowWalkere
Do you mean you want to generate a random 10-char id each time a user is registered? Seems a bit strange, but it's do-able...

Code:

$letters = array ('a', 'b', 'c', 'd', ... 'z');    // Define 26 letters into an array
$uid = "";    Initialize $uid to a blank string

$col = 0;
while ($col++ < 10)
{
  $slot = rand(0, 25);    //  Loop ten times, add a random char
  $uid = $uid . $letters["$slot"];
}

// Connect to DB here, check if $uid already exists, and then upload


Or, instead of a random generator, you could have the user supply an id in the registration form. Then, check the DB to see if a row already exists with that id. If it doesn't, the registration is uploaded successfully, otherwise an error is printed and the user is sent back to the registration form.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.