diff --git a/.DS_Store b/.DS_Store index 41e1cef..5008ddf 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/comment.php b/comment.php new file mode 100644 index 0000000..7b66c0a --- /dev/null +++ b/comment.php @@ -0,0 +1,95 @@ +"; +if(isset($_POST['view_reply_parent'])) +{ +$_SESSION['view_reply_parent'] = $_POST['view_reply_parent']; +} +$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(); + ?> + + ";//refresh the page + } + catch(Exception $e) + { + die(var_dump($e)); + } +} + +//display the parent message +$sql_select = "SELECT msg_id,msg, username,msg_time,uid + FROM messages, users + WHERE messages.uid = users.user_id AND messages.msg_id = $parent_id"; +$res=$conn->prepare($sql_select); +$res->execute(); +?> + + + + + fetch(PDO::FETCH_OBJ)) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
MessageByTime
".$row -> msg."".$row -> username."".$row -> msg_time."

"; + +//display the replys to that message + +$sql_select = "SELECT cmt,cmt_id,username,cmt_time + FROM comments + INNER JOIN messages ON $parent_id=comments.parent_id AND parent_id = messages.msg_id + INNER JOIN users ON users.user_id = comments.uid + ORDER BY cmt_time DESC "; +$res=$conn->prepare($sql_select); +$res->execute(); +if($res->rowCount()!=0) +{ +?> + + + + + fetch(PDO::FETCH_OBJ)) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
RepliesByTime
".$row -> cmt."".$row -> username."".$row -> cmt_time."
"; +} +else +{ + echo "
"; + echo "

No replies here

"; + echo "
"; +} +?> +
+ + "; ?> +
+ +
+
+Go Back \ No newline at end of file diff --git a/dbconnect.php b/dbconnect.php index 0b25f09..b83133a 100644 --- a/dbconnect.php +++ b/dbconnect.php @@ -1,9 +1,11 @@ setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); + $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);//sql injection prevention } catch(Exception $e){ die(var_dump($e)); diff --git a/icons/delete.png b/delete.png similarity index 100% rename from icons/delete.png rename to delete.png diff --git a/header.php b/header.php new file mode 100644 index 0000000..ec7293f --- /dev/null +++ b/header.php @@ -0,0 +1,26 @@ + + + + + +Welcome - <?php echo $userRow['email']; ?> + + + + \ No newline at end of file diff --git a/home.php b/home.php index dba0b0c..9dad9a4 100644 --- a/home.php +++ b/home.php @@ -1,8 +1,5 @@ query($sql_select); $userRow=$res->fetch(PDO::FETCH_BOTH); -if(isset($_POST["delete_action"])) +if(isset($_POST["delete_action"]))//deleting message part { if($_POST["delete_action"]=="delete") { @@ -25,9 +22,6 @@ $stmt = $conn->prepare($sql_del); $stmt->bindValue(1,$_POST["del_msg_id"]); $stmt->execute(); - ?> - - - - - - -Welcome - <?php echo $userRow['email']; ?> - - - -

Bulletin Board

@@ -81,6 +57,7 @@ By Time Delete + Replies fetch(PDO::FETCH_OBJ)) { @@ -95,20 +72,43 @@ "; + echo ""; + } + else + { + echo ""; + echo "
"; + echo ""; + echo "
"; + } + } echo ""; } @@ -141,7 +141,7 @@ ?> "; + echo "";//refresh the page } catch(Exception $e) { diff --git a/search.php b/search.php index 7f445d0..e8116bb 100644 --- a/search.php +++ b/search.php @@ -1,95 +1,79 @@ - - - - -Welcome - <?php echo $userRow['email']; ?> - - - - -
- Search Results of '".$_POST['message_target']."'"; - ?> -
- -query($sql_search); - if(count($result) > 0) - { - ?> - - - - - - fetch(PDO::FETCH_OBJ)) + echo "
"; + echo "

Search Results of '".$_POST['message_target']."'

"; + echo "
"; + try { - echo ""; - echo ""; - echo ""; - if($_SESSION['user']==$row->uid) + $sequence = '%'.$_POST['message_target'].'%'; + $search = "SELECT msg_id,msg, username,msg_time,uid + FROM messages, users + WHERE messages.uid = users.user_id AND msg LIKE ? + ORDER BY `messages`.`msg_time` DESC"; + $stmt = $conn->prepare($search); + $stmt->bindValue(1,$sequence,PDO::PARAM_STR); + $stmt->execute(); + if($stmt->rowCount()!=0) { - ?> - - + echo "
"; + echo "

".$stmt->rowCount()." results:

"; + echo "
"; + ?> +
MessageByTimeDelete
".$row -> msg."".$row -> username."".$row -> msg_time." -
-
+ + + + fetch(PDO::FETCH_OBJ)) + { + echo ""; + echo ""; + echo ""; + if($_SESSION['user']==$row->uid) + { + ?> + + + "; + } + } + echo "
MessageByTimeDelete
".$row -> msg."".$row -> username."".$row -> msg_time." +
+
"; } - else + else { - echo ""; + echo "
"; + echo "

No results!
Please review your input !

"; + echo "
"; } } - echo ""; + catch(Exception $e) + { + die(var_dump($e)); + } } else { - echo "No message here ! be the first !"; -} - - } - catch(Exception $e) - { - die(var_dump($e)); - } + echo "
"; + echo "

Error on search !
Please make sure that you had entered a valid input !

"; + echo "
"; } ?> Go Back \ No newline at end of file diff --git a/style.css b/style.css index 3c382bf..f6fec3c 100644 --- a/style.css +++ b/style.css @@ -147,17 +147,16 @@ textarea#msg_search_box{ } button#msg_submit{ border: 2px solid #fafafa; -width: 20%; - margin-left:40px; - height:45px; - background:#3e94ec; - background:-moz-linear-gradient(top, #595959 , #515151); - border-radius:3px; - color:#f9f9f9; - font-family:Verdana, Geneva, sans-serif; - font-size:18px; - font-weight:bolder; - text-transform:uppercase; +width: 30%; +height:45px; +background:#3e94ec; +background:-moz-linear-gradient(top, #595959 , #515151); +border-radius:3px; +color:#f9f9f9; +font-family:Verdana, Geneva, sans-serif; +font-size:25px; +font-weight:bolder; +text-transform:uppercase; } button#msg_search{ border: 2px solid #fafafa; @@ -173,7 +172,20 @@ button#msg_search{ font-weight:bolder; text-transform:uppercase; } - +button#view_replies +{ + border:0; + font-size: 25px; + color:#4e5066; + background: transparent; +} +button#view_replies:hover +{ + border:0; + font-size: 25px; + color:#fafafa; + background: transparent; +} /* css for home page */ /* imported table style */ @@ -191,7 +203,7 @@ body { div.table-title { display: block; margin-left:40px; - max-width: 600px; + max-width: 1000px; padding:5px; width: 100%; } @@ -203,7 +215,6 @@ div.table-title { font-style:normal; font-family: "Roboto", helvetica, arial, sans-serif; text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.1); - text-transform:uppercase; } @@ -213,7 +224,6 @@ div.table-title { background: white; border-radius:3px; border-collapse: collapse; - height: 320px; margin-left:40px; width: 70%; padding:5px; @@ -228,7 +238,7 @@ th { border-right: 1px solid #343a45; font-size:23px; font-weight: 100; - padding:24px; + padding:10px; text-align:left; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); vertical-align:middle; @@ -345,7 +355,7 @@ button#del_btn } a#back_to_home { - margin-left: 40px; + margin-left: 45px; color: #fafafa; font-size: 30px; font-weight: 400;