Here is my CODE. I’m using php 5.4 and the PDO connection! I included my database connection and some other files i need. And now I have a registration form wich i add some values from filling them. The ridirection is made and not a problem is shown. But when I check the DB is not added. Where I’m going wrong?
<?php
include'db.php';
include'header.php';
require 'vendndodhje.php';
$VendndodhjeInput = new Vendndodhje();
if ( !empty($_POST)) {
// keep track validation errors
$emerError = null;
$mbiemerlError = null;
$dtlError = null;
$telError = null;
$emailError = null;
$vendndodhjeError=null;
// keep track post values
$emer = $_POST['emer'];
$mbiemer = $_POST['mbiemer'];
$datelindje = $_POST['datelindje'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$Vendndodhje=$_POST['Vendndodhje'];
// validate input
$valid = true;
if (empty($emer)) {
$emerError = 'Ju lutemi plotesoni emrin!';
$valid = false;
}
if (empty($mbiemer)) {
$mbiemerError = 'Ju lutemi plotesoni mbiemrin!';
$valid = false;
}
if (empty($datelindje)) {
$dtlError = 'Ju lutemi plotesoni datelindjen tuaj!';
$valid = false;
}
if (empty($tel)) {
$telError = 'Ju lutemi plotesoni numrin tuaj te telefonit!';
$valid = false;
}
if (!$VendndodhjeInput ->isValid($Vendndodhje)) {
$vendndodhjeError = 'Ju lutemi plotesoni piken e marketit me te afert per te terhequr karten!';
$valid = false;
}
if (empty($email)) {
$emailError = 'Ju lutemi plotesoni email-in tuaj!';
$valid = false;
} else if ( !filter_var($email,FILTER_VALIDATE_EMAIL) ) {
$emailError = 'Ju lutemi vendosni nje adrese email-i te rregullt!';
$valid = false;
}
//insert values
if ($valid) {
$pdo = Database::connect();
$sql = "INSERT INTO klienti(emer,mbiemer,datelindje,tel,email,Vendndodhje,date_aplikimi) VALUES(?, ?, ?, ?, ?, ?, NOW())";
$q = $pdo->prepare($sql);
$q->execute(array($emer, $mbiemer, $datelindje, $tel,$email, $Vendndodhje));
}
header("Location: form'.php");
}
?>