I'm planning a source for php membership, but how can I not allow you to join with an ID that is already in the DB when you sign up for membership?

Asked 2 years ago, Updated 2 years ago, 33 views

I'm planning a source for php membership, but how can I not allow you to join with an ID that is already in the DB when you sign up for membership?

mysql php

2022-09-21 18:00

1 Answers

There are two methods, and it is recommended that you apply both methods

How to hang UNIQUE in the ID column index in the database.

If you hang it like this, the insert will be canceled if the ID part is duplicated during the insert

It is a method of double checking the ID at php logic unit, but it is a method of using the ID that has been requested when signing up.

This is how it works, so you have to adjust it moderately

// Get ID value
$id = $_POST['id'];

// Run the query below to get the results
// Find the $id value just received for id in the user table
// The reason I did 0 is because I didn't have to do *
SELECT 0 FROM 'User Table' WEHRE id = $id

// If there's anything from the data I just got,
if( TRUE ) {

    ID is Jungbok;

} } else {

    Membership registration completed;

}

This is what it looks like this is what it looks like. The import part depends on the function of db you use, so you can modify it


2022-09-21 18:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.