Praca Programisty client
- Szczegóły
- Kategoria: Praca Programista
- Opublikowano: piątek, 11, październik 2013 16:53
- Super User
- Odsłony: 52477
Praca Programisty Client
Do pliku server_client_kategoria.php klienta zaimportowałem klasę połączenie z bazą danych, którą wcześniej zrobiłem.
<?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'])){ /* Zapis do bazy */ /* tabela kategoria ---- id, kategoria, data */ try{ $db = new databaseclass; $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $db->prepare('INSERT INTO `kategoria` (`kategoria`, `data_kategoria`) VALUES ( :kategoria, NOW())'); $stmt->bindValue(':kategoria', $_POST['nazwa_kategori'], 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_ko"; } }else{ echo "blad_api"; }