<?php

require ".././model/Contato.class.php";
$contato = new Contato();
if (isset($_POST["vchNome"]) && $_POST['vchNome'] != '') {
    $contato->setVchNome($_POST["vchNome"]);
} else {
    header("location:../index.php?str=erro");
}
if (isset($_POST["vchEmail"]) && $_POST['vchEmail'] != '') {
    $contato->setVchEmail($_POST["vchEmail"]);
} else {
    header("location:../index.php?str=erro");
}
if (isset($_POST["vchAssunto"]) && $_POST['vchAssunto'] != '') {
    $contato->setVchAssunto($_POST["vchAssunto"]);
} else {
    header("location:../index.php?str=erro");
}
if (isset($_POST["txtMensagem"]) && $_POST['txtMensagem'] != '') {
    $contato->setTxtMsg($_POST["txtMensagem"]);
} else {
    header("location:../index.php?str=erro");
}
$con = new PDO("mysql:host=mysql.hostinger.com.br;dbname=u157910548_aluno", "u157910548_jack", "j34602796");
//$con = new PDO("mysql:host=localhost;dbname=u157910548_aluno","root","");
$stmt = $con->prepare('insert into contatos(vchNome,vchEmail,vchAssunto,txtMensagem) values (?,?,?,?)');
$stmt->bindValue(1, $contato->getVchNome());
$stmt->bindValue(2, $contato->getVchEmail());
$stmt->bindValue(3, $contato->getVchAssunto());
$stmt->bindValue(4, $contato->getTxtMsg());