-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.php
More file actions
38 lines (31 loc) · 956 Bytes
/
update.php
File metadata and controls
38 lines (31 loc) · 956 Bytes
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
<?php
include("functions.php");
$id=$_GET["id"];
//入力チェック(受信確認処理追加)
if(
!isset($_POST["title"]) || $_POST["title"]=="" ||
!isset($_POST["content"]) || $_POST["content"]==""
){
exit('ParamError');
}
//POSTデータ取得
$title = $_POST["title"];
$content = $_POST["content"];
//2. DB接続します(エラー処理追加)
$pdo = db_con();
//3.データ登録SQL作成
$stmt = $pdo->prepare("UPDATE blog_table SET title = :title, content=:content WHERE id = :id");
$stmt->bindValue(':title', $title, PDO::PARAM_STR);
$stmt->bindValue(':content', $content, PDO::PARAM_STR);
$stmt->bindValue(':id', $id, PDO::PARAM_INT);
$status = $stmt->execute();
//4.データ登録処理後
if($status==false){
//SQL実行時にエラーがある場合(エラーオブジェクト取得して表示)
err_db_Info($stmt);
}else{
//5.index.phpへリダイレクト
header("Location: up_ok.php");
exit;
}
?>