How to pass business id to the employee table? [closed]

3

I have a company table and another employee.

Company table :

id_emp | tipo | documento | fantasia | email | celular | senha | data_cadastro | ativo

Example:

 1 | pessoa juridica | 05.142.333/0001-21 | petstop caes e gatos | [email protected] | (21) 8651-0801 | MD5 | 22/11/2015 | 09:49:00 | 1

Employee table :

id_func | sexo | nome | sobrenome | funcao | celular | email | senha | ativo | data_cadastro | id_emp  

Example:

1 | M | Paulo | Santos | veterinario | (21)8651-0001 | [email protected] | MD5 | 1 | 22/11/2015 | 09:49:00 | 1 | ???

Before my question, I will inform the procedure that I do to get here: On my site, the company (petstop caes and gatos) registers it. After registration, the system sends a link to the registered email ([email protected]) with the MD5 password. And, there is a link to the activation of it. When it activates, just below it, it logs in.

I made using this example here .

An employee registration form has been created, ie after logging in, it will register the employee, and after saving in the employee table, associate this with the company.

    
asked by anonymous 22.11.2015 / 14:01

2 answers

2

You can put a field in the form with type="hidden" and with ID of the company being value of that field.

When you submit the form, you capture the value of this field and save it in the id_emp column in the funcionário table. For example:

<input type="hidden" name="id_emp" value="1">
    
22.11.2015 / 15:53
0

This would actually be a relationship with primary key id_emp in table empresa and foreign key id_emp in table funcionario . In phpmyadmin itself you can create the indexes and then create the relationship between these two tables.

Follow link for reference: video

    
22.11.2015 / 18:45