beginTransaction(); $sql = "update phptest1.greet set subject=?, content=?, is_html=? where num=?"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $subject, PDO::PARAM_STR); $stmh->bindValue(2, $content, PDO::PARAM_STR); $stmh->bindValue(3, $html_ok, PDO::PARAM_STR); $stmh->bindValue(4, $num, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); header("Location:http://localhost/greet/list.php"); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } } else { if ($html_ok =="y"){ $is_html = "y"; }else { $is_html = ""; $content = htmlspecialchars($content); } try{ $pdo->beginTransaction(); $sql = "insert into phptest1.greet(id,name,nick,subject,content,regist_day,hit,is_html) "; $sql .= "values(?, ?, ?, ?, ?, now(), 0, ?)"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $_SESSION["userid"], PDO::PARAM_STR); $stmh->bindValue(2, $_SESSION["name"], PDO::PARAM_STR); $stmh->bindValue(3, $_SESSION["nick"], PDO::PARAM_STR); $stmh->bindValue(4, $subject, PDO::PARAM_STR); $stmh->bindValue(5, $content, PDO::PARAM_STR); $stmh->bindValue(6, $is_html, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); header("Location:http://localhost/greet/list.php"); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: ".$Exception->getMessage(); } } ?>