1
Good afternoon. I have a simple form of an agenda that records the location data, event name and etc, then I have another one that records the participating users, I would like to know how I got the ID of that previous form (event recording). To record in the attendee form, and then you can list.
Recording form first
Case 'salvar';
$data = '';
$data = implode('-', array_reverse(explode('/', $_POST['data_agenda'])));
if (app::$key) {
$sql = "update agenda set compromisso_agenda='" . $_POST["compromisso_agenda"] . "'
,data_agenda='$data',hora_agenda='" . $_POST["hora_agenda"] . "',pessoa_agenda='" . $_POST["pessoa_agenda"] . "',local_agenda='" . $_POST["local_agenda"] . "' where id_agenda=" . app::$key;
} else {
$sql = "insert into agenda (compromisso_agenda,data_agenda,hora_agenda,pessoa_agenda,local_agenda)
values ( '" . $_POST["compromisso_agenda"] . "','$data','" . $_POST["hora_agenda"] . "','" . $_POST["pessoa_agenda"] . "','" . $_POST["local_agenda"] . "')";
}
$dados = connection::exec($sql);
header('Location: ' . URL . 'agenda/pessoas');
break;
Recording according to form
case 'salvar-pessoa':
$agendap_id = fetchColumn(0);
if (app::$key) {
$sql = "update agendap set agendap_id='$agendap_id',agendap_pessoa='" . $_POST["agendap_pessoa"] . "' where id_agenda=" . app::$key;
} else {
$sql = "insert into agendap (agendap_id,agendap_pessoa)
values ( '$agendap_id','" . $_POST["agendap_pessoa"] . "')";
}
$dados = connection::exec($sql);
header('Location: ' . URL . 'agenda/exibir');
break;
Or else Insert into foreign key tables with PDO
– rray