Skip to content

Commit ae5836c

Browse files
committed
Added a Home page for the Forum
1 parent bdf8e90 commit ae5836c

File tree

8 files changed

+159
-31
lines changed

8 files changed

+159
-31
lines changed

forum/connect.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
$link = mysqli_connect($database['host'] , $database['username'] , $database['password'] , $database['name'] );
1212

1313
if($link){
14-
echo "<b>Successfully</b> connected to database : " . $database['name'] . "<br/><br/>";
14+
//echo "<b>Successfully</b> connected to database : " . $database['name'] . "<br/><br/>";
1515
}
1616
else {
17-
echo "Coonection to database " . $database['name'] . " <b>FAILED</b> <br/>";
17+
echo "Conection to database " . $database['name'] . " <b>FAILED</b> <br/>";
1818
echo "Error is => " . mysql_error();
1919
}
2020

forum/header.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- This is a header that contains -->
2+
<!-- Home Page -->
3+
<!-- My Account -->
4+
<!-- Members -->
5+
<!-- Logout -->
6+
7+
<center>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href = "index.php">Home Page</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href = "account.php"> My Account</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href = "members.php"> Members</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href = "index.php?action=logout"> Logout </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</center>

forum/index.php

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,47 @@
1-
<!-- Login page without Fancy Frontend -->
1+
<!-- This is the Home Page for the Forum -->
2+
3+
<?php
4+
5+
session_start();
6+
require('connect.php');
7+
8+
if (@$_SESSION["username"]):
9+
?>
10+
11+
<!--echo "Welcome " . $_SESSION['username'] . " !!<br/>";-->
212

313
<!DOCTYPE html>
14+
<html>
15+
<head>
16+
17+
<meta charset="utf-8" />
18+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
19+
<title>CODEX - Forum</title>
20+
<meta name="viewport" content="width=device-width, initial-scale=1">
21+
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
22+
<script src="main.js"></script>
23+
24+
</head>
25+
26+
<body>
27+
28+
<?php include("header.php"); ?>
29+
30+
</body>
31+
32+
</html>
33+
34+
35+
<?php
36+
37+
else :
38+
echo "Please <a href = 'login2.php'>Login</a> to continue";
39+
endif;
40+
41+
if (@$_GET['action'] == "logout")
42+
{
43+
session_destroy();
44+
echo "<script>location='login2.php'</script>";
45+
}
446

5-
<html lang="en-US">
6-
<head>
7-
<meta charset="utf-8" />
8-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
9-
<title>CODEX FORUM</title>
10-
<meta name="viewport" content="width=device-width, initial-scale=1">
11-
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
12-
<script src="main.js"></script>
13-
</head>
14-
<body>
15-
<form action = "login_parse.php" method = "POST">
16-
Username : <input type = "text" name = "username" placeholder="Enter your Username"><br><br>
17-
Password &nbsp;: <input type="password" name = "password" placeholder="Enter your Password"><br><br>
18-
<input type="submit" name="login" value="LOGIN">
19-
</form>
20-
</body>
21-
</html>
47+
?>

forum/index2.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- Login page without Fancy Frontend -->
2+
3+
<!DOCTYPE html>
4+
5+
<html lang="en-US">
6+
<head>
7+
<meta charset="utf-8" />
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
9+
<title>CODEX FORUM</title>
10+
<meta name="viewport" content="width=device-width, initial-scale=1">
11+
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
12+
<script src="main.js"></script>
13+
</head>
14+
<body>
15+
<form action = "login_parse.php" method = "POST">
16+
Username : <input type = "text" name = "username" placeholder="Enter your Username"><br><br>
17+
Password &nbsp;: <input type="password" name = "password" placeholder="Enter your Password"><br><br>
18+
<input type="submit" name="login" value="LOGIN">
19+
</form>
20+
</body>
21+
</html>

forum/login2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<html lang="en" >
55

66
<head>
7-
<title>Institute of Technical Education & Research</title>
7+
<title>CODEX - Login</title>
88
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
99
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
1010
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">

forum/login_parse.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22
//Login Functions
33

4-
include("connect.php");
5-
include("forum_functions.php");
4+
session_start(); //To start sessional storage
5+
include("connect.php"); //To link to database
6+
include("forum_functions.php"); //To include neccessary functions
67

7-
$username = $_POST['username'];
8+
$username = $_POST['username']; //Gets username and password by the post method.
89
$password = $_POST['password'];
910

1011
// echo "Username : " . $username . "<br/><br/> Password : " . $password;
@@ -20,10 +21,16 @@
2021
else
2122
{
2223

23-
if( checkInvalidCharacters($username))
24+
if( checkInvalidCharacters($username)) //If there are any invalid chars in username
2425
echo "Username can only contain <br/><br/><ul><li> A to Z </li><li> a to z </li><li> 0 to 9 </li><li> . and _ </li></ul>";
2526

26-
else
27+
//To check if the user hsa created an account or not
28+
elseif (mysqli_num_rows(mysqli_query($link , "SELECT * FROM forum.users WHERE username = '".$username."'")) == 0)
29+
{
30+
echo "<h1>Username Not Found!!</h1> <br/><br/> You can Register here <br/><br/> <a href='register2.php'>Register</a>";
31+
}
32+
33+
else //If there are no invalid chars
2734
{
2835
$sql = "
2936
SELECT password FROM forum.users
@@ -36,11 +43,14 @@
3643
$stmt->bind_result($hashedPswd);
3744

3845
$stmt->fetch();
39-
if(crypt($password , $hashedPswd) == $hashedPswd )
46+
if(crypt($password , $hashedPswd) == $hashedPswd ) //If encrypting current password == encrypted password in database
4047
{
4148
echo "<b>Successfully Logged In</b>";
49+
$_SESSION["username"] = $username;
50+
//header("Location : ");
51+
echo "<script>location='index.php'</script>";
4252
}
43-
else
53+
else //If not then...
4454
{
4555
echo "<b>Wrong Password</b><br/>Please enter the correct password ";
4656
}

forum/members.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!-- This is the Home Page for the Forum -->
2+
3+
<?php
4+
5+
include("connect.php");
6+
session_start();
7+
require('connect.php');
8+
9+
if (@$_SESSION["username"]):
10+
?>
11+
12+
<!--echo "Welcome " . $_SESSION['username'] . " !!<br/>";-->
13+
14+
<!DOCTYPE html>
15+
<html>
16+
<head>
17+
18+
<meta charset="utf-8" />
19+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
20+
<title>Members of this forum</title>
21+
<meta name="viewport" content="width=device-width, initial-scale=1">
22+
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
23+
<script src="main.js"></script>
24+
25+
</head>
26+
27+
<body>
28+
29+
<?php
30+
31+
include("header.php");
32+
33+
echo "<center><h1>Registered Members</h1>";
34+
35+
$check = mysqli_query($link , "SELECT * FROM forum.users");
36+
$rows = mysqli_num_rows($check);
37+
38+
while ($row = mysqli_fetch_assoc($check))
39+
{
40+
$id = $row['id'];
41+
echo "<a href = 'profile.php?id=$id'>" . $row['username'] . "</a><br/><br/>" ;
42+
}
43+
echo "</center>";
44+
45+
?>
46+
47+
</body>
48+
49+
</html>
50+
51+
52+
<?php
53+
54+
else :
55+
echo "Please <a href = 'login2.php'>Login</a> to continue";
56+
endif;
57+
58+
if (@$_GET['action'] == "logout")
59+
{
60+
session_destroy();
61+
echo "<script>location='login2.php'</script>";
62+
}
63+
64+
?>

forum/register2.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<html lang="en" >
55

66
<head>
7-
<title>Institute of Technical Education & Research</title>
7+
<title>CODEX - Register</title>
88
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
9-
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
10-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
9+
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
1111
1212
1313
<style>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy