-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_update.php
More file actions
47 lines (38 loc) · 1.17 KB
/
user_update.php
File metadata and controls
47 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
// 「語り」を編集する
session_start();
include("funcs.php");
ss_chg();
avoid();
$id = $_POST["id"];
$title = $_POST["title"];
$content = $_POST["content"];
// -------------------------------おばけポイント部分(途中)
$user_id = $_SESSION["user_id"];
$hoge = $_POST["hoge"];
// dbへ接続
$pdo = db_conn();
// g-point
if($hoge=="1"){
$sql = "UPDATE users SET g_point = g_point+1 WHERE user_id=:user_id";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':user_id', $user_id, PDO::PARAM_STR);
$status = $stmt->execute();
}
// ----------------------------------
//DB接続
$pdo = db_conn();
//データ登録SQL作成
$sql = "UPDATE stories SET title = :title, content = :content WHERE id = :id";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':title', $title, PDO::PARAM_STR); //Integer(数値の場合 PDO::PARAM_INT)
$stmt->bindValue(':content', $content, PDO::PARAM_STR); //Integer(数値の場合 PDO::PARAM_INT)
$stmt->bindValue(':id', $id, PDO::PARAM_INT); //Integer(数値の場合 PDO::PARAM_INT)
$status = $stmt->execute(); //実行
//データ登録処理後
if($status==false){
sql_error();
}else{
redirect("mystory.php");
}
?>