When you sign up
How do I check if the username isnt taken, and the email isnt taken
then if they're both not taken store username & password & email & gender (radio button) into MySQL
Storing username & passwords & e-mails & gender
Moderator: General Moderators
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
hmm
I know, but how do I check through MySQL, and how do I even add them to the DataBase? O_O
Create unique indices for both fields username and email (each). Mysql will not allow the same value twice for such fields.
instead of inserting the doublet mysql will then set the error
Code: Select all
CREATE TABLE `tablename` (
`id` int(11) unsigned NOT NULL auto_increment,
`username` varchar(255) NOT NULL default '',
`email` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_username` (`username`),
UNIQUE KEY `idx_email` (`email`)
)You can fetch the error code 1062 via mysql_errnohttp://dev.mysql.com/doc/refman/5.1/en/error-messages-server.html wrote:#
Error: 1062 SQLSTATE: 23000 (ER_DUP_ENTRY)
Message: Duplicate entry '%s' for key '%s'
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
ok
Ok, I put the SQL stuff into the SQL section in the PHPmyadmin tab, but how do I add data to it lol?
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
hmm
Errrm, meaning what?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA