note 127955 added to pdo.prepare

From: Date: Tue, 22 Nov 2022 22:12:13 +0000
Subject: note 127955 added to pdo.prepare
Groups: php.notes 
Request: Send a blank email to php-notes+get-219910@lists.php.net to get a copy of this message
<?php namespace Fotofreunde\Controller; use Fotofreunde\Model\PhotoModel; use Fotofreunde\Library\View; class PhotoController { protected $view; private $db; private $validData = array(); private $errors = array(); private $labels = array("title" => "Bildtitel" , "filename" => "Bilddatei: Lfd-Nr." , "categoryId" => "Kategorie" , "description" => "alt. Bildtext"); public function __construct($view) { $this->db = new PhotoModel(); $this->view = $view; } public function showPhotoForm() { $this->view->setVars([ 'labels' => $this->labels, 'validData' => $this->validData, 'errors' => $this->errors ]); } public function showPhotos() { } public function validateData() { foreach ($this->labels as $index => $value) { if (!isset($_POST[$index]) || empty($_POST[$index])) { $this->errors[$index] = "Bitte " . $value . " angeben<br>"; } elseif ($index == 'filename' && !file_exists('images/'.$_POST[$index])) { $this->errors[$index] = "Bilddatei " . $_POST[$index] . " existiert nicht"; } elseif ($index == 'title' && strlen($_POST[$index]) > 80) { $this->errors[$index] = "Bitte nicht mehr als 80 Zeichen angeben"; } elseif ($index == 'description' && filter_var($_POST[$index], FILTER_VALIDATE)) else { $this->validData[$index] = $_POST[$index]; } } $this->validData["userId"] = $_POST["userId"]; if (count($this->errors) > 0) { $this->view->setDoMethodName('showPhotoForm'); $this->showPhotoForm(); } else { if ($this->db->writePhotoData($this->validData)) { $this->view->setDoMethodName("showPhotos"); $this->showPhotos(); } } } } ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.159.161 (proxied: 2001:16b8:1885:e000:192b:f3a7:b3bc:c8de) ---- Manual Page -- https://php.net/manual/en/pdo.prepare.php Edit -- https://main.php.net/note/edit/127955 Del: integrated -- https://main.php.net/note/delete/127955/integrated Del: useless -- https://main.php.net/note/delete/127955/useless Del: bad code -- https://main.php.net/note/delete/127955/bad+code Del: spam -- https://main.php.net/note/delete/127955/spam Del: non-english -- https://main.php.net/note/delete/127955/non-english Del: in docs -- https://main.php.net/note/delete/127955/in+docs Del: other reasons-- https://main.php.net/note/delete/127955 Reject -- https://main.php.net/note/reject/127955 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219910) next »