this is my code below and error
<?php
session_start();
include('../config/dbconnect.php');
$a = $_POST['name'];
$b = $_POST['office'];
$c = $_POST['zone'];
$d = $_POST['phone'];
$e = $_POST['email'];
// query
$file_name = strtolower($_FILES['file']['name']);
$file_ext = substr($file_name, strrpos($file_name, '.'));
$prefix = 'vtu_'.md5(time()*rand(1, 9999));
$file_name_new = $prefix.$file_ext;
$path = '../uploads/'.$file_name_new;
/* check if the file uploaded successfully */
if(@move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
//do your write to the database filename and other details
$sql = "INSERT INTO excosssss (name,office,zone,phone,email,file) VALUES (:a,:b,:c,:d,:e,:f)";
$q = $db->prepare($sql);
$q->execute(array(':a'=>$a,':b'=>$b,':c'=>$c,':d'=>$d,':e'=>$e,':f'=>$file_name_new));
if($q){
header("location:profile.php?success=true");
}else{
header("location:profile.php?failed=true");
}
}
?>
/** ERROR
Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘email’
cannot be null in C:\Program Files\Ampps\www\newChurch\admin\save-excosssss.php:32 Stack trace:
#0 C:\Program Files\Ampps\www\newChurch\admin\save-excosssss.php(32): PDOStatement->execute(Array)
#1 {main} thrown in C:\Program Files\Ampps\www\newChurch\admin\save-excosssss.php on line 32
*/
I TRIED ANOTHER MEANS, BUT IT IS NOT WORKING
<?php
include '../config/dbconnect.php';
$name = $_POST['name'];
$office = $_POST['office'];
$zone = $_POST['zone'];
$phone = $_POST['phone'];
$email = $_POST['email'];
// This code will save file into the database
$query = ORM ::for_table('excos')->create();
$query->name=$name;
$query->office=$office;
$query->zone=$zone;
$query->phone=$phone;
$query->email = $email;
$query->save();
if($query){
header("location:profile.php?success=true");
}else{
header("location:profile.php?failed=true");
}
?>
/** ERROR
Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘email’
cannot be null in C:\Program Files\Ampps\www\newChurch\admin\save-excosssss.php:25 Stack trace:
#0 C:\Program Files\Ampps\www\newChurch\admin\save-excosssss.php(25): PDOStatement->execute(Array)
#1 {main} thrown in C:\Program Files\Ampps\www\newChurch\admin\save-excosssss.php on line 25
*/