I have a online page which will allow user to create ac acoount for them inorder to acceess our page.
I worry in some period, there will be a lots of user who create at the same time. In that case, I worry my database will be clash or conflict.
Can i know is that anyway to prevent that happens ?
My table as below :
CREATE TABLE user (
id int(11) NOT NULL,
userid varchar(30) DEFAULT NULL,
password varchar(20) DEFAULT NULL,
name varchar(40) DEFAULT NULL
)
ALTER TABLE user
ADD PRIMARY KEY (id);
ADD UNIQUE KEY userid (participant_id);
ALTER TABLE user
MODIFY id int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
COMMIT;
So my id will be just number and auto increment. userid wil be unique.
I created the page by using PHP. And i use following insert command at my page :
do {
$query = "INSERT IGNORE INTO user(userid, password, name) VALUES ('$userid','$password','$name')";
$insert = $conn->query($query);
} while( $insert && ($conn -> affected_rows == 0) );
Are this code can work perfectly to prevent the date conflit ?
Another extra question is, how about if i create another extra page which will insert information 'user' table and can i used the same code at the new page ??