Page 1 of 1

Storing username & passwords & e-mails & gender

Posted: Sat Dec 02, 2006 9:27 pm
by Mythic Fr0st
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

Posted: Sat Dec 02, 2006 9:43 pm
by me!
Use an "if" in your registration form validation. If its taked tell them they need to use something different.

hmm

Posted: Sat Dec 02, 2006 9:46 pm
by Mythic Fr0st
I know, but how do I check through MySQL, and how do I even add them to the DataBase? O_O

Posted: Sat Dec 02, 2006 9:50 pm
by volka
Create unique indices for both fields username and email (each). Mysql will not allow the same value twice for such fields.

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`)
)
instead of inserting the doublet mysql will then set the error
http://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'
You can fetch the error code 1062 via mysql_errno

ok

Posted: Sat Dec 02, 2006 9:55 pm
by Mythic Fr0st
Ok, I put the SQL stuff into the SQL section in the PHPmyadmin tab, but how do I add data to it lol?

Re: ok

Posted: Sun Dec 03, 2006 12:41 am
by hrubos
Mythic Fr0st wrote:Ok, I put the SQL stuff into the SQL section in the PHPmyadmin tab, but how do I add data to it lol?
import on tab in PhpMyAdmin.

hmm

Posted: Sun Dec 03, 2006 12:45 am
by Mythic Fr0st
Errrm, meaning what?

Posted: Sun Dec 03, 2006 1:20 am
by RobertGonzalez
How new are you to PHP? What I mean by that is have you ever coded any INSERT/UPDATE/DELETE queries before?