Praca Programisty client 1
- Szczegóły
- Kategoria: Praca Programista
- Opublikowano: piątek, 11, październik 2013 16:57
- Super User
- Odsłony: 40253
Praca Programisty client 1
Tak jak poprzednio zimportowałem połączenie z bazą danych.
<?php include_once (dirname(__FILE__) . '/'.basename('databaseclass.php')); /* * @version Komentarze zdalnie v1.0 * @autor Adam Berger$ * Copyright 2013 Komentarze zdalnie * ber34$o2.pl * Licensed under the Apache License v2.0 * <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a> * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
if($_POST['id_key'] == md5("1234")){ /* Czyscimy ze smieci jak potrzeba */ if(!empty($_POST['nazwa_kategori'])){ if(!empty($_POST['nazwa_komentarz'])){ /* Zapis do bazy */ /* tabela komentarz ---- id_komentarz, kategoria, komentarz, data */ try{ $db = new databaseclass; $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $db->prepare('INSERT INTO `komentarz` (`kategoria`, `komentarz`, `data_komentarz`) VALUES ( :kategoria, :komentarz, NOW())'); $stmt->bindValue(':kategoria', $_POST['nazwa_kategori'], PDO::PARAM_STR); $stmt->bindValue(':komentarz', $_POST['nazwa_komentarz'], PDO::PARAM_STR); $stmt->execute(); if($stmt->rowCount() > 0){ echo "ok"; }else{ echo "blad_zapytania"; } }catch(PDOException $e){ return 'Połączenie nie mogło zostać utw.<br />'.$e->getMessage(); } }else{ echo "blad_k"; } }else{ echo "blad_ko"; } }else{ echo "blad_api"; }