Skip to content

Commit

Permalink
Different view for logged out
Browse files Browse the repository at this point in the history
New Post and New Comment forms don't appear for logged in users.
TODO: Make login.php and logout.php redirect to previous page.
  • Loading branch information
clubby789 committed Aug 16, 2017
1 parent fd27dba commit 00c9868
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
Binary file modified images/Thumbs.db
Binary file not shown.
13 changes: 9 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@


<center>
<button onClick="togglePost()" class="loginButton">New Post</button>
<?php if(isset($cookie))
{
echo("<button onClick='togglePost()' class='loginButton'>New Post</button>");
}
else
{
echo("<p>Login to make a post</p>");
}
?>
</center>
<div id="newPost">

</div>
<hr>
<ul style="align: center;">
<li>Sort By:</li>
Expand Down
9 changes: 7 additions & 2 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<html>
<head>
<title>Login</title>
<?php include("header.php"); ?>
<?php include("header.php");

?>

<script type="text/javascript">
var loginStr = `
Expand All @@ -17,6 +19,7 @@
<input class="loginButton" type="submit" value ="Log in" title="Log in"/>
<br/>
<input type="hidden" name="submissionType" value="login" />

</form>
`;

Expand All @@ -30,6 +33,7 @@
<input class="loginButton" type="submit" value ="Register" title="Register" />
<br/>
<input type="hidden" name="submissionType" value="register" />

</form>
`;
var count = 0
Expand Down Expand Up @@ -90,9 +94,10 @@ function initTips() {
}

if ($dbPass == $passwordHashed) {
echo("<script>alert('That was the right password.')</script>");
setCookie("IDCookie",$loginID);
echo($p);
header('Location: index.php');


} else {
echo("<script>alert('That was the wrong password.')</script>");
Expand Down
26 changes: 19 additions & 7 deletions thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,33 @@
echo('</center>');
?>

<div id="newComment" style="width: 80%; padding-left: 20px" >
</br>
</br>
<?php if(isset($cookie))
{
echo("
<div id='newComment' style='width: 80%; padding-left: 20px' >
<center>
<h2 class="newThreadTitle" style="text-align: left; font-family: Gill Sans, Gill Sans MT, Myriad Pro, DejaVu Sans Condensed, Helvetica, Arial; ">New Comment</h2>
<h2 class='newThreadTitle' style='text-align: left; font-family: Gill Sans, Gill Sans MT, Myriad Pro, DejaVu Sans Condensed, Helvetica, Arial;' >New Comment</h2>
</center>
<form style=" padding-top: 5%" action="/commentUpload.php" target="_blank" method="post" id="newComment" enctype="multipart/form-data">
<input type="text" name="content" placeholder="Comment" style="width: 50%"/> <br /> <br />
<input class="loginButton" type="submit" value ="Submit" title="Submit" name="submit"/>
<br /> <input type="hidden" name="isNewPost" value="true" />
<input type="hidden" name="thread" value="<?php echo($threadID); ?>" />
<form style= 'padding-top: 5%' action='/commentUpload.php' target='_blank' method='post' id='newComment' enctype='multipart/form-data'>
<input type='text' name='content' placeholder='Comment' style='width: 50%'/> <br /> <br />
<input class='loginButton' type='submit' value ='Submit' title='Submit' name='submit'/>
<br /> <input type='hidden' name='isNewPost' value='true' />
<input type='hidden' name='thread' value='<?php echo($threadID); ?>' />
</form>
</div>
");
}
else
{
echo("<center><p>Login to make a comment</p></center>");
}
?>

</body>
<footer>
Expand Down

0 comments on commit 00c9868

Please sign in to comment.