Skip to content

Commit

Permalink
Blank input prevention,left-margins for msg/cmt submit buttons set
Browse files Browse the repository at this point in the history
-Attempt to fix message time zone problem
To Do List:
Comments.php:fked up column alignment,deletion
  • Loading branch information
hiimdoublej committed May 31, 2016
1 parent 5e93388 commit abd8ef4
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 40 deletions.
50 changes: 30 additions & 20 deletions comment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
date_default_timezone_set("Asia/Taipei");
include_once 'header.php';
echo "<br>";
if(isset($_POST['view_reply_parent']))
Expand All @@ -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();
?>
<script>alert('successfully sent reply');</script>
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();
?>
<script>alert('successfully sent reply');</script>
<?php
echo "<meta http-equiv='refresh' content='0'>";//refresh the page
}
catch(Exception $e)
{
die(var_dump($e));
}
}
else
{
?>
<script>alert('Please check your input !');</script>
<?php
echo "<meta http-equiv='refresh' content='0'>";//refresh the page
}
catch(Exception $e)
{
die(var_dump($e));
}
}
}

//display the parent message
Expand Down
4 changes: 3 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
date_default_timezone_set("Asia/Taipei");
session_start();
include_once 'dbconnect.php';
if(!isset($_SESSION['user']))
Expand All @@ -9,8 +10,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>410221009 bboard</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['email']; ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
Expand All @@ -20,6 +21,7 @@
</div>
<div id="right">
<div id="content">
<a href="https://github.com/hiimdoublej/dbms2016">Github</a>
hi' <?php echo $_SESSION['username'];?>&nbsp;<a href="logout.php?logout">Sign Out</a>
</div>
</div>
Expand Down
44 changes: 26 additions & 18 deletions home.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
date_default_timezone_set("Asia/Taipei");
include_once 'header.php';
if(!isset($_SESSION['user']))
{
Expand Down Expand Up @@ -127,26 +128,33 @@
<?php
if(isset($_POST['submit']))
{
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();
?>
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();
?>
<script>alert('successfully sent message');</script>
<?php
echo "<meta http-equiv='refresh' content='0'>";//refresh the page
}
catch(Exception $e)
{
die(var_dump($e));
}
echo "<meta http-equiv='refresh' content='0'>";//refresh the page
}
catch(Exception $e)
{
die(var_dump($e));
}
else
{
?>
<script>alert('Please check your input !');</script>
<?php
}
}
?>
</body>
Expand Down
7 changes: 7 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
date_default_timezone_set("Asia/Taipei");
session_start();
include_once 'dbconnect.php';

Expand Down Expand Up @@ -43,7 +44,13 @@
<div id="left">
<label>410221009 DBMS final project</label>
</div>
<div id ="right">
<div id = "content">
<a href="https://github.com/hiimdoublej/dbms2016">Github</a>
</div>
</div>
</div>
</div>
<center>
<div id="login-form">
<form method="post">
Expand Down
1 change: 1 addition & 0 deletions phpinfo.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?php
date_default_timezone_set("Asia/Taipei");
phpinfo();
3 changes: 2 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ textarea#msg_search_box{
}
button#msg_submit{
border: 2px solid #fafafa;
width: 30%;
width: 40%;
height:45px;
background:#3e94ec;
background:-moz-linear-gradient(top, #595959 , #515151);
Expand All @@ -157,6 +157,7 @@ font-family:Verdana, Geneva, sans-serif;
font-size:25px;
font-weight:bolder;
text-transform:uppercase;
margin-left: 40px;
}
button#msg_search{
border: 2px solid #fafafa;
Expand Down

0 comments on commit abd8ef4

Please sign in to comment.