From abd8ef447df45f070a3015b2d22560f8c3c5976a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E9=96=8E=E5=82=91?= Date: Tue, 31 May 2016 21:11:04 +0800 Subject: [PATCH] Blank input prevention,left-margins for msg/cmt submit buttons set -Attempt to fix message time zone problem To Do List: Comments.php:fked up column alignment,deletion --- comment.php | 50 ++++++++++++++++++++++++++++++-------------------- header.php | 4 +++- home.php | 44 ++++++++++++++++++++++++++------------------ index.php | 7 +++++++ phpinfo.php | 1 + style.css | 3 ++- 6 files changed, 69 insertions(+), 40 deletions(-) diff --git a/comment.php b/comment.php index 7b66c0a..0d118a3 100644 --- a/comment.php +++ b/comment.php @@ -1,4 +1,5 @@ "; if(isset($_POST['view_reply_parent'])) @@ -8,27 +9,36 @@ $parent_id = $_SESSION['view_reply_parent']; if(isset($_POST['submit_comment'])) { - try - { - $uid = $_SESSION['user']; - $msg = $_POST['comment']; - $time = date('Y/m/d H:i:s'); - $insert = "INSERT INTO comments(cmt,uid,cmt_time,parent_id) VALUES(?,?,?,?)"; - $stmt = $conn->prepare($insert); - $stmt->bindValue(1,$msg); - $stmt->bindValue(2,$uid); - $stmt->bindValue(3,$time); - $stmt->bindValue(4,$parent_id); - $stmt->execute(); - ?> - + if($_POST['comment']!='') + { + try + { + $uid = $_SESSION['user']; + $msg = $_POST['comment']; + $time = date('Y/m/d H:i:s'); + $insert = "INSERT INTO comments(cmt,uid,cmt_time,parent_id) VALUES(?,?,?,?)"; + $stmt = $conn->prepare($insert); + $stmt->bindValue(1,$msg); + $stmt->bindValue(2,$uid); + $stmt->bindValue(3,$time); + $stmt->bindValue(4,$parent_id); + $stmt->execute(); + ?> + + ";//refresh the page + } + catch(Exception $e) + { + die(var_dump($e)); + } + } + else + { + ?> + ";//refresh the page - } - catch(Exception $e) - { - die(var_dump($e)); - } + } } //display the parent message diff --git a/header.php b/header.php index ec7293f..378d3cc 100644 --- a/header.php +++ b/header.php @@ -1,4 +1,5 @@ +410221009 bboard -Welcome - <?php echo $userRow['email']; ?> @@ -20,6 +21,7 @@ diff --git a/home.php b/home.php index 9dad9a4..944c84e 100644 --- a/home.php +++ b/home.php @@ -1,4 +1,5 @@ prepare($insert); - $stmt->bindValue(1,$msg); - $stmt->bindValue(2,$uid); - $stmt->bindValue(3,$time); - $stmt->execute(); - ?> + if($_POST['message']!='') + try + { + $uid = $userRow['user_id']; + $msg = $_POST['message']; + $time = date('Y/m/d H:i:s'); + $insert = "INSERT INTO messages(msg,uid,msg_time) VALUES(?,?,?)"; + $stmt = $conn->prepare($insert); + $stmt->bindValue(1,$msg); + $stmt->bindValue(2,$uid); + $stmt->bindValue(3,$time); + $stmt->execute(); + ?> ";//refresh the page - } - catch(Exception $e) - { - die(var_dump($e)); - } + echo "";//refresh the page + } + catch(Exception $e) + { + die(var_dump($e)); + } + else + { + ?> + + diff --git a/index.php b/index.php index fac3e21..8a768e6 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ + +
diff --git a/phpinfo.php b/phpinfo.php index bfd863b..7e82b64 100644 --- a/phpinfo.php +++ b/phpinfo.php @@ -1,2 +1,3 @@