0
I would like to add in the field registered the functionname logged in to database.
<?php
require_once("../../../session.php");
require_once("../../../class.user.php");
$auth_user = new USER();
$user_id = $_SESSION['user_session'];
$stmt = $auth_user->runQuery("SELECT * FROM cad_funcionarios WHERE id_funcionario=:id_funcionario");
$stmt->execute(array(":id_funcionario"=>$user_id));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
$stmt = $auth_user->runQuery('INSERT INTO cadastro_clientes (numerocontrato, id_cpf_cnpj, nome_completo, adesao, cpfoucnpj, cpfoucnpjnumero, data_nascimento, email, cep, rua, numero, bairro, cidade, estado, id_vendedor, id_forma_pagamento, id_forma, id_sexo, data_vencimento, id_revenda, id_plano, id_acomodacao, telefone, celular, total, cadastradopor, data_hora_cadastro, nomedependente, cpfdependente, datanascimentodependente, planodependente, acomodacaodependente, grauparentescodependente, valordependente) VALUES (:numerocontrato, :id_cpf_cnpj, :nome_completo, :adesao, :cpfoucnpj, :cpfoucnpjnumero, :data_nascimento, :email, :cep, :rua, :numero, :bairro, :cidade, :estado, :id_vendedor, :id_forma_pagamento, :id_forma, :id_sexo, :data_vencimento, :id_revenda, :id_plano, :id_acomodacao, :telefone, :celular, :total, :cadastradopor, NOW(), :nomedependente, :cpfdependente, :datanascimentodependente, :planodependente, :acomodacaodependente, :grauparentescodependente, :valordependente)');
foreach ($_POST['usuarios'] as $usuario) {
$usuario['numerocontrato']= $_POST['numerocontrato'];
$usuario['id_cpf_cnpj']= $_POST['id_cpf_cnpj'];
$usuario['nome_completo']= $_POST['nome_completo'];
$usuario['adesao']= $_POST['adesao'];
$usuario['cpfoucnpj']= $_POST['cpfoucnpj'];
$usuario['cpfoucnpjnumero'] = $_POST['cpfoucnpjnumero'];
$usuario['data_nascimento'] = date('Y-m-d',strtotime($_POST['data_nascimento']));
$usuario['email'] = $_POST['email'];
$usuario['cep'] = $_POST['cep'];
$usuario['rua'] = $_POST['rua'];
$usuario['numero'] = $_POST['numero'];
$usuario['bairro'] = $_POST['bairro'];
$usuario['cidade'] = $_POST['cidade'];
$usuario['estado'] = $_POST['estado'];
$usuario['id_vendedor'] = $_POST['id_vendedor'];
$usuario['id_forma_pagamento'] = $_POST['id_forma_pagamento'];
$usuario['id_forma'] = $_POST['id_forma'];
$usuario['id_sexo'] = $_POST['id_sexo'];
$usuario['data_vencimento'] = date('Y-m-d',strtotime($_POST['data_vencimento']));
$usuario['id_revenda'] = $_POST['id_revenda'];
$usuario['id_plano'] = $_POST['id_plano'];
$usuario['id_acomodacao'] = $_POST['id_acomodacao'];
$usuario['telefone'] = $_POST['telefone'];
$usuario['celular'] = $_POST['celular'];
$usuario['total']= $_POST['total'];
$stmt->execute($usuario);
}
echo 'Cadastro realizado com sucesso<br><br>';
echo "<h1>" . $userRow['nome_funcionario'] . "</h1>";
//header('refresh:6;cad_usuarios.php');
?>
What is the logic of this
foreach
? oo ... Could you edit the question? It’s too vague, there’s no session variable there, how will you save in the bank if there are no such variables?– Leonardo
This foreach serves to record the data of the responsével + the dependent @lvcs I do not know how to do or how to place the session
– Mauro Santos
"id of a user logged in to the database" - Which user are you talking about?
root
? If not, how do these users dologon
?– ShutUpMagda
@Maurosantos it seems to me that the
foreach
always takes the same data, so I do not understand, I think it is the case that you edit the question by putting what you want to do, but in the question there is only code, explain what you want to do, with details.– Leonardo
You accepted an answer that has nothing to do with what you were asked. Edit your question.
– ShutUpMagda
Welcome to Stackoverflow in English. I edited your question to remove the greetings as we usually keep the text as clean as possible to focus on your scheduling question. If you are interested in visiting a part of the site that is not aimed to ask questions can know the [chat]. If you have questions about the operation, rules and procedures of the site visit the [meta] :)
– Sorack