initial commit
This commit is contained in:
38
servicos/inc_ser.php
Normal file
38
servicos/inc_ser.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
if (session_status() !== PHP_SESSION_ACTIVE){
|
||||
session_start();
|
||||
}
|
||||
$nome=(empty($_POST["nome"])) ? " ": $_POST["nome"];
|
||||
$id_categoria=(empty($_POST["id_categoria"])) ? 0 : $_POST["id_categoria"];
|
||||
$id_prestador=(empty($_POST["id_prestador"])) ? NULL : $_POST["id_prestador"];
|
||||
|
||||
|
||||
include('../conexao.php');
|
||||
|
||||
$query= "INSERT INTO servicos (servico, id_categoria) VALUES ('$nome', '$id_categoria')";
|
||||
$resu= mysqli_query($con,$query);
|
||||
$id_servico;
|
||||
if ($id_servico = mysqli_insert_id($con)) {
|
||||
if($id_prestador !== NULL)
|
||||
{
|
||||
$sql = "INSERT INTO prestadores_servicos (id_prestador, id_servico) VALUES (?,?)";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bind_param('ss',$id_prestador,$id_servico);
|
||||
if($stmt->execute())
|
||||
{
|
||||
$_SESSION['msg']= "<p style='color:blue;'> Serviço cadastrado com sucesso!</p>";
|
||||
header('Location: index.php');
|
||||
}
|
||||
else{
|
||||
$_session['msg']= "<p style='color:red;'> Serviço não foi cadastrado!</p>";
|
||||
header('Location: index.php');
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
}
|
||||
else{
|
||||
$_session['msg']= "<p style='color:red;'> Serviço não foi cadastrado!</p>";
|
||||
header('Location: index.php');
|
||||
}
|
||||
mysqli_close($con);
|
||||
?>
|
Reference in New Issue
Block a user