Ich habe folgende Klassenmethodemysql/php INSERT-Abfrage Problem
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');
}
Meine Form Werte senden, ich habe es mit var_dump($_POST['username'])
hier ist create()
Methode
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();
}
meiner Datenbank richtig angeschlossen weil mein Authentifizierungssystem funktioniert. Aber diese Abfrage fügt nichts ein. Was ist falsch an meinem Code? Danke für Hilfe.
Alle Fehler zurückgegeben oder alles glatt? –
'stmt-> errorInfo()' Funktion –
@HonzaRydrych haben diese Warnungen 'Hinweis: Undefinierter Index: Text in /home/hue/test/controllers/SiteController.php on line 21 Hinweis: Undefinierter Index: Bild in/home /hue/test/controllers/SiteController.php in Zeile 22' –