Beispiel #1
0
$dbh = new PDO("mysql:host={$servername}; dbname={$db};", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$data = $_POST['data'];
$type = $_POST['type'];
$values = split(',', $data);
if ($type == 'kit') {
    addKit($values, $dbh);
}
if ($type == 'log') {
    addLog($values, $dbh);
}
if ($type == 'comment') {
    addComment($values, $dbh);
}
if ($type == 'challange') {
    addChallange($values, $dbh);
}
if ($type == 'chComment') {
    addChComment($values, $dbh);
}
if ($type == 'site') {
    addSite($values, $dbh);
}
if ($type == 'like') {
    like($values, $dbh);
}
function addKit($json, $db)
{
    $ins = $db->prepare("insert into Kit (image, brand, model, item, date, userId) \n        values (?, ?, ?, ?, ?, ?);") or die(print_r($dbh->errorInfo(), true));
    $ins->bindParam(1, $json[0]);
    $ins->bindParam(2, $json[1]);
Beispiel #2
0
//$json = $_GET['kit'];
if (isset($_GET['kit'])) {
    $json = $_GET['kit'];
    addKit($json, $dbh);
}
if (isset($_GET['log'])) {
    $json = $_GET['log'];
    addLog($json, $dbh);
}
if (isset($_GET['comment'])) {
    $json = $_GET['comment'];
    addComment($json, $dbh);
}
if (isset($_GET['challange'])) {
    $json = $_GET['challange'];
    addChallange($json, $dbh);
}
if (isset($_GET['chComment'])) {
    $json = $_GET['chComment'];
    addChComment($json, $dbh);
}
if (isset($_GET['site'])) {
    $json = $_GET['site'];
    addSite($json, $dbh);
} else {
}
function addKit($json, $db)
{
    $array = split(',', $json);
    $ins = "insert into Kit (image, brand, model, item, date, userId) \n        values ('{$array['0']}', '{$array['1']}', '{$array['2']}', '{$array['3']}', '{$array['4']}','{$array['5']}');" or die(print_r($dbh->errorInfo(), true));
    $db->query($ins);