Skip to main content
Update wording
Source Link

Overall this is a lot of procedural code to process. That is fine to use but I would suggest you look into an MVC structure, or at least OOP - abstracting bits of code into controller methods and other functions or static methods that can be called by these pages, as well as tested by unit tests. I know that might be a lot to expect from a beginner but it is worth learning about and utilizing.

The code already uses require for mail.php. I would suggest abstracting the repeated function random_str() into a single file, along with any other common functions, and then using require to include it wherever necessary, which would be congruentinline with the Don't Repeat Yourself principle. That way any updates to the function can be done in one spot instead of multiple. If you use OOP/MVC techniques as recommended above, that function could be static method of a class - e.g. Authentication, AuthenticationController, Registration, RegistrationController, etc.

Also, those variables listed at the top of registration.php which do not change can be stored as constants - either with define() or the const keyword - especially the latter if there is an appropriate class created to associate those with. And a common convention for constants is for them to be named using all capitalized letters. While this is not a requirement, many believe it helps when reading the code to distinguish constants from other values.

The sequential queries in registration.php i.e. "SELECT * FROM acc WHERE serial=?" and "SELECT verify FROM acc WHERE serial=?" make me wonder if serial is a primary/foreign key of one or both of those tables, and if those two queries could be combined into a single query where the tables are JOINed one those fields.

It would be a good habit to use the Identical comparison operator (i.e. ===) where appropriate instead of the Equal comparison operator (i.e. ==) unless you are sure that type-juggling is fine for your use case. And the same is true for the Not Identical Operator (i.e. !==) vs Not equal (i.e. != or <>).

Overall this is a lot of procedural code to process. That is fine to use but I would suggest you look into an MVC structure, or at least OOP - abstracting bits of code into controller methods and other functions or static methods that can be called by these pages, as well as tested by unit tests. I know that might be a lot to expect from a beginner but it is worth learning about and utilizing.

The code already uses require for mail.php. I would suggest abstracting the repeated function random_str() into a single file and then using require to include it wherever necessary, which would be congruent with the Don't Repeat Yourself principle. If you use OOP/MVC techniques as recommended above, that function could be static method of a class - e.g. Authentication, AuthenticationController, Registration, RegistrationController, etc.

Also, those variables listed at the top of registration.php which do not change can be stored as constants - either with define() or the const keyword - especially the latter if there is an appropriate class created to associate those with. And a common convention for constants is for them to be named using all capitalized letters. While this is not a requirement, many believe it helps when reading the code to distinguish constants from other values.

The sequential queries in registration.php i.e. "SELECT * FROM acc WHERE serial=?" and "SELECT verify FROM acc WHERE serial=?" make me wonder if serial is a primary/foreign key of one or both of those tables, and if those two queries could be combined into a single query where the tables are JOINed one those fields.

It would be a good habit to use the Identical comparison operator (i.e. ===) where appropriate instead of the Equal comparison operator (i.e. ==) unless you are sure that type-juggling is fine for your use case. And the same is true for the Not Identical Operator (i.e. !==) vs Not equal (i.e. != or <>).

Overall this is a lot of procedural code to process. That is fine to use but I would suggest you look into an MVC structure, or at least OOP - abstracting bits of code into controller methods and other functions or static methods that can be called by these pages, as well as tested by unit tests. I know that might be a lot to expect from a beginner but it is worth learning about and utilizing.

The code already uses require for mail.php. I would suggest abstracting the repeated function random_str() into a single file, along with any other common functions, and then using require to include it wherever necessary, which would be inline with the Don't Repeat Yourself principle. That way any updates to the function can be done in one spot instead of multiple. If you use OOP/MVC techniques as recommended above, that function could be static method of a class - e.g. Authentication, AuthenticationController, Registration, RegistrationController, etc.

Also, those variables listed at the top of registration.php which do not change can be stored as constants - either with define() or the const keyword - especially the latter if there is an appropriate class created to associate those with. And a common convention for constants is for them to be named using all capitalized letters. While this is not a requirement, many believe it helps when reading the code to distinguish constants from other values.

The sequential queries in registration.php i.e. "SELECT * FROM acc WHERE serial=?" and "SELECT verify FROM acc WHERE serial=?" make me wonder if serial is a primary/foreign key of one or both of those tables, and if those two queries could be combined into a single query where the tables are JOINed one those fields.

It would be a good habit to use the Identical comparison operator (i.e. ===) where appropriate instead of the Equal comparison operator (i.e. ==) unless you are sure that type-juggling is fine for your use case. And the same is true for the Not Identical Operator (i.e. !==) vs Not equal (i.e. != or <>).

added 100 characters in body
Source Link

Overall this is a lot of procedural code to process. That is fine to use but I would suggest you look into an MVC structure, or at least OOP - abstracting bits of code into controller methods and other functions or static methods that can be called by these pages, as well as tested by unit tests. I know that might be a lot to expect from a beginner but it is worth learning about and utilizing.

The code already uses require for mail.php. I would suggest abstracting the repeated function random_str() into a single file and then using require to include it wherever necessary, which would be congruent with the Don't Repeat Yourself principle. If you use OOP/MVC techniques as recommended above, that function could be static method of a class - e.g. Authentication, AuthenticationController, Registration, RegistrationController, etc.

Also, those variables listed at the top of registration.php which do not change can be stored as constants - either with define() or the const keyword - especially the latter if there is an appropriate class created to associate those with. And a common convention for constants is for them to be named using all capitalized letters. While this is not a requirement, many believe it helps when reading the code to distinguish constants from other values.

The sequential queries in registration.php i.e. "SELECT * FROM acc WHERE serial=?" and "SELECT verify FROM acc WHERE serial=?" make me wonder if serial is a primary/foreign key of one or both of those tables, and if those two queries could be combined into a single query where the tables are JOINed one those fields.

It would be a good habit to use the Identical comparison operator (i.e. ===) where appropriate instead of the Equal comparison operator (i.e. ==) unless you are sure that type-juggling is fine for your use case. And the same is true for the Not Identical Operator (i.e. !==) vs Not equal (i.e. != or <>).

Overall this is a lot of procedural code to process. That is fine to use but I would suggest you look into an MVC structure, or at least OOP - abstracting bits of code into controller methods and other functions or static methods that can be called by these pages, as well as tested by unit tests.

The code already uses require for mail.php. I would suggest abstracting the repeated function random_str() into a single file and then using require to include it wherever necessary, which would be congruent with the Don't Repeat Yourself principle. If you use OOP/MVC techniques as recommended above, that function could be static method of a class - e.g. Authentication, AuthenticationController, Registration, RegistrationController, etc.

Also, those variables listed at the top of registration.php which do not change can be stored as constants - either with define() or the const keyword - especially the latter if there is an appropriate class created to associate those with. And a common convention for constants is for them to be named using all capitalized letters. While this is not a requirement, many believe it helps when reading the code to distinguish constants from other values.

The sequential queries in registration.php i.e. "SELECT * FROM acc WHERE serial=?" and "SELECT verify FROM acc WHERE serial=?" make me wonder if serial is a primary/foreign key of one or both of those tables, and if those two queries could be combined into a single query where the tables are JOINed one those fields.

It would be a good habit to use the Identical comparison operator (i.e. ===) where appropriate instead of the Equal comparison operator (i.e. ==) unless you are sure that type-juggling is fine for your use case. And the same is true for the Not Identical Operator (i.e. !==) vs Not equal (i.e. != or <>).

Overall this is a lot of procedural code to process. That is fine to use but I would suggest you look into an MVC structure, or at least OOP - abstracting bits of code into controller methods and other functions or static methods that can be called by these pages, as well as tested by unit tests. I know that might be a lot to expect from a beginner but it is worth learning about and utilizing.

The code already uses require for mail.php. I would suggest abstracting the repeated function random_str() into a single file and then using require to include it wherever necessary, which would be congruent with the Don't Repeat Yourself principle. If you use OOP/MVC techniques as recommended above, that function could be static method of a class - e.g. Authentication, AuthenticationController, Registration, RegistrationController, etc.

Also, those variables listed at the top of registration.php which do not change can be stored as constants - either with define() or the const keyword - especially the latter if there is an appropriate class created to associate those with. And a common convention for constants is for them to be named using all capitalized letters. While this is not a requirement, many believe it helps when reading the code to distinguish constants from other values.

The sequential queries in registration.php i.e. "SELECT * FROM acc WHERE serial=?" and "SELECT verify FROM acc WHERE serial=?" make me wonder if serial is a primary/foreign key of one or both of those tables, and if those two queries could be combined into a single query where the tables are JOINed one those fields.

It would be a good habit to use the Identical comparison operator (i.e. ===) where appropriate instead of the Equal comparison operator (i.e. ==) unless you are sure that type-juggling is fine for your use case. And the same is true for the Not Identical Operator (i.e. !==) vs Not equal (i.e. != or <>).

Source Link

Overall this is a lot of procedural code to process. That is fine to use but I would suggest you look into an MVC structure, or at least OOP - abstracting bits of code into controller methods and other functions or static methods that can be called by these pages, as well as tested by unit tests.

The code already uses require for mail.php. I would suggest abstracting the repeated function random_str() into a single file and then using require to include it wherever necessary, which would be congruent with the Don't Repeat Yourself principle. If you use OOP/MVC techniques as recommended above, that function could be static method of a class - e.g. Authentication, AuthenticationController, Registration, RegistrationController, etc.

Also, those variables listed at the top of registration.php which do not change can be stored as constants - either with define() or the const keyword - especially the latter if there is an appropriate class created to associate those with. And a common convention for constants is for them to be named using all capitalized letters. While this is not a requirement, many believe it helps when reading the code to distinguish constants from other values.

The sequential queries in registration.php i.e. "SELECT * FROM acc WHERE serial=?" and "SELECT verify FROM acc WHERE serial=?" make me wonder if serial is a primary/foreign key of one or both of those tables, and if those two queries could be combined into a single query where the tables are JOINed one those fields.

It would be a good habit to use the Identical comparison operator (i.e. ===) where appropriate instead of the Equal comparison operator (i.e. ==) unless you are sure that type-juggling is fine for your use case. And the same is true for the Not Identical Operator (i.e. !==) vs Not equal (i.e. != or <>).