<?php
/**
* Created by JetBrains PhpStorm.
* User: Oldřich Taufer
* Date: 8.8.13
* Time: 8:44
* To change this template use File | Settings | File Templates.
*/
require_once __DIR__ . '/db_config.php';
mysql_connect(DB_SERVER,DB_USER,DB_PASSWORD);
mysql_select_db(DB_DATABASE);
mysql_query("SET NAMES 'utf-8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_general_ci'");
$response = array();
if(login()){
// check for required fields
if (
isset($_POST['zakaznik'])
&& isset($_POST['zacatek'])
&& isset($_POST['konec'])
&& isset($_POST['datum'])
&& isset($_POST['km'])
&& isset($_POST['technik'])
&& isset($_POST['popis'])
) {
$zakaznik= $_POST['zakaznik'];
$zacatek= $_POST['zacatek'];
$konec= $_POST['konec'];
$datum= $_POST['datum'];
$km= $_POST['km'];
$technik= $_POST['technik'];
$popis= $_POST['popis'];
$vytvoreno= date("Y-m-d H:i:s");
$sql= "INSERT INTO zakazka
(
zakaznik,
zacatek,
konec,
datum,
pocet_km,
technik,
popis,
vytvoreno) VALUES(
'$zakaznik',
'$zacatek',
'$konec',
'$datum',
'$km',
'$technik',
'$popis',
'$vytvoreno'
) ";
// mysql inserting a new row
$result = mysql_query($sql);
// check if row inserted or not
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "Successfully created.";
// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
$response["message"] = "Oops! An error occurred.";
// echoing JSON response
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}}
function login(){
if (isset($_POST['name']) && isset($_POST[('pass')])){
$name= ($_POST['name']);
$pass= ($_POST['pass']);
$salt= '%mZEd48uW';
$npass=sha1($pass . str_repeat($salt, 10));
$q= mysql_query("SELECT id FROM uzivatel WHERE username='$name' && password='$npass'");
if($q){
return true;
}else{
return false;
}
} else{
return false;
}
}
?>
Zdravim vsechny, potreboval bych se poradit. Php skript mi zde slouzi pouze pro komunikaci s aplikaci pro android. Data se odesilaji i prijimaji tak jak maji, ale misto diakritika se mi zobrazuji otazniky. Zasilam zde svuj kod a prosim o pomoc v tom, kde by mohla byt chyba.