I have following class method
public function index()
{
$username = '';
$email = '';
$text = '';
$picture = '';
if (isset($_POST['submit']))
{
$username = $_POST['username'];
$email = $_POST['email'];
$text = $_POST['text'];
$picture = $_POST['picture'];
Task::create($username, $email, $text, $picture);
}
require_once(ROOT.'/views/site/index.php');
}
My form send values, i checked it with var_dump($_POST['username'])
here is create()
method
public static function create($username, $email, $text, $picture='1', $check_token=false)
{
$db = Db::connect();
$query = 'INSERT INTO tasks (username, email, text, picture, check_token)
VALUES (:username, :email, :text, :picture, :check_token)';
$result = $db->prepare($query);
$result->bindParam(':username', $username, PDO::PARAM_STR);
$result->bindParam(':email', $email, PDO::PARAM_STR);
$result->bindParam(':text', $text, PDO::PARAM_STR);
$result->bindParam(':picture', $picture, PDO::PARAM_STR);
$result->bindParam(':check_token', $check_token, PDO::PARAM_STR);
$result->execute();
}
my database connected properly cause my auth system works. But this query does not insert anything. Whatis wrong with my code? Thanks for help.