Welcome Guest, Not a member yet? Register   Sign In
Need your suggestions on a project's "thinking".
#1

Hey guys,
I'm currently creating a CI project and i'm really stuck on how to cope with a situation i face. So i thought the best way to solve it was to ask someone who's more advanced here.

The situation is the following: 
I have 3 tables with data: Users, Contact info and  Pets.
These are all joined.

There will be non-registered and registered users. 

The non-registered users will submit a form with some data on (e.g. email, name and phone number) and i want from my side:
1) To check if email exists in table #1 named "Users",
2) If exists get the user_id of the existing user,
3) pass this user_id, together with phone in table #2 Contact_info
4) then finally, passing the user_id + newly created contact info id + all the other form data to table #3 Users.

The thing is that i also have upload file function in my controller and this kinda confused me.

Any ideas on how can i make it work?! 

Thank you very much!

//Life motto
if (sad() == true) {
     sad().stop();
     develop();
}
Reply
#2

You need a unique PIN (at least 10 digit alpha-numeric value) for each user. It will be stored in the User table (#1).

It is not sufficient to match only the email address before writing information to the Contact_info table. Someone could submit a fictitious set of information if all they need is the email address. I would reject any NEW registration if it uses an email address which is already in your Contact_info table. Only one registration allowed for each email address.

Table #3 is probably some other name than "Users" because that is your name for table #1. Perhaps you meant "Pets" as the name for table #3?

This is how I would configure these three tables

Users
-id unique, auto-increment primary key
-PIN unique

Contact_Info
-user_id link pointing to Users:id
-name encrypted
-email encrypted

Pets
-user_id link pointing to Users:id
-pet_name
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB