Skip to content
Snippets Groups Projects
Commit 2bf2d6a5 authored by Haoyu Yin's avatar Haoyu Yin
Browse files

first edit

parents
No related branches found
No related tags found
No related merge requests found
<?php
include "code.php";
//database connection
?>
<!DOCTYPE html>
<html>
<title></title>
<link rel="stylesheet" type="text/css" href="css/styleM.css"><!--styling the login page-->
<body>
<div class="contain row">
<div class="com-md-6">
<h2 class="text-center">Login</h2><hr/>
<form action="code.php" method="POST">
Username:<input type="text" name="username" placeholder="Username" required></br><br> <!--presence check-->
Password: <input type="password" name="password" placeholder="Password" required>
<p class="text-center" style="color:red;">
<?php echo $_message; ?>
</p>
<div class="form-group">
<input type="submit" name="btnLogin" class="btn btn-primary" value="Login">
</div>
</form>
</div>
</div>
</body>
</html>
<style><!--styling-->
input{
margin-right: 50%;
float: right;
}
.contain {
margin:auto;
width: 500px;
border:1px white;
padding: 10px;
margin-top:10px;
background-color:#f5f5f0;
height:190px;
}
</style>
<?php
// To make sure we don't need to create the header section of the website on multiple pages, we instead create the header HTML markup in a separate file which we then attach to the top of every HTML page on our website. In this way if we need to make a small change to our header we just need to do it in one place. This is a VERY cool feature in PHP!
require "header.php";
?>
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style> <!--styling inside the styling tab-->
body11111 {font-family: "Times New Roman", Georgia, Serif;}
h1, h2, h3, h4, h5, h6 {
font-family: "Playfair Display";
letter-spacing: 5px;
}
img {
float: left;
padding-right:100px;
margin:15px;
padding-top:70px;
}
h1{
padding-top:70px;
}
p{
padding-top:30px;
}
</style>
<body1>
<!-- Page content -->
<div>
<!-- About Section -->
<div>
<div>
<h1>Y-Chess</h1><br><!--things which will be displayed inside the event page-->
<h5></h5>
<p>Y-chess is a professional chess rating association which aims to give people the best advice on their Chess gameplay and rate their games which played during the events that the association holds. They are currently holds:
Cardiff Youth U17, U18, Rapid & Blitz Chess Championship
Universal Chess Foundation FIDE Rating Chess Tournament
Welsh Rapid Championship
Welsh Blitz Championship
Y-Chess tournaments involves two players sit headed to head and play their chess games over a Chess board and each moves that they have made will be recorded by themselves.
The recorded moves will then be sent to Y-Chess and being rated.
Y-Chess company is currently Based in Cardiff Bute Street CF10 5AF
</p>
<p></p>
</div>
</div>
</body>
</html>
<?php
// To make sure we don't need to create the header section of the website on multiple pages, we instead create the header HTML markup in a separate file which we then attach to the top of every HTML page on our website. In this way if we need to make a small change to our header we just need to do it in one place. This is a VERY cool feature in PHP!
require "footer.php";
?>
\ No newline at end of file
<?php
session_start();
//start the session for the user login
if(isset($_SESSION['role'])){
if($_SESSION['role'] != 'Admin'){ //cehcks the role of the user
header("Location:staff.php");
}
}
else{
header('Location:M-login.php'); //bring the user to the login page
}
require "admin_header.php"; //take the staff header so that if the header requires to be changed, I only have to do it in one place
?>
<!DOCTYPE html>
<html>
<title></title>
<!--page content-->
</html>
<!DOCTYPE html>
<html>
<head>
<main>
<section class="index-banner">
<div class="vertical-center">
<h2>Y-Chess: Track your progress <br>through your games</h2>
<h1>Y-Chess allows you to have your own unique chess rating<br> based on your games and give you the most suitable rating<br> based on your performance.</h1>
</div>
</section>
<div class="wrapper">
<section class="index-links">
<a href='event.php'>
<div class="index-boxlink-square">
<h3>Events</h3>
</div>
</a>
<a href='#'>
<div class="index-boxlink-rectangle">
<h3>How to use Y-Chess</h3>
</div>
</a>
<a href='#'>
<div class="index-boxlink-square">
<h3>About</h3>
</div>
</section>
</main>
</div>
</head>
<body>
<?php
// To make sure I don't need to create the header section of the website on multiple page
require "footer.php";
?>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="This is an example of a meta description. This will often show up in search results.">
<meta name=viewport content="width=device-width, initial-scale=1">
<title></title>
<link rel="stylesheet" href="style2.css">
<!--applying the style sheet to the header-->
</head>
<body>
<header>
<a class="header-logo" href="index.php">Y-Chess</a>
<!--the image logo-->
<nav class="nav-header-main">
<!--style the shape of the header-->
<ul><!--header navigation-->
<li><a href="admin.php">Home</a></li>
<li><a href="tour_setup.php">SET UP Tournament</a></li>
<li><a href="update.php">Update rating</a></li>
</ul>
</nav>
<?php
echo '<p class="login-status">WELCOME '.$_SESSION['AdminUser'].'</p></ br></ br></ br>';
//displayed the session of the user who is logged in
?>
</header>
</body>
</html>
\ No newline at end of file
<?php
include "header2.php";
//require function which takes the code from other files and run it here to ensure if I need to change anything, I can do it in one file only
?>
<h1>Tournament page</h1>
<div class="article-container">
<?php
$title = mysqli_real_escape_string($conn_tournament, $_GET['title']);
//gets the input and escape the special characters for title
$date = mysqli_real_escape_string($conn_tournament, $_GET['date']);
//gets the input and escape the special characters for date
$sql = "SELECT * FROM article WHERE a_title='$title' AND a_date='$date'";
//select all data from article and set title and store the title and date inside their variables
$result = mysqli_query($conn_tournament, $sql);
//performs a query against the database
$queryResults = mysqli_num_rows($result);
if ($queryResults > 0) { //check the data in the database
while($row = mysqli_fetch_assoc($result)){
//fetch associative array
echo "<div class='article-box'>
<h3>".$row['a_title']."</h3>
<p>".$row['a_text']."</p>
<p>".$row['a_date']."</p>
<p>".$row['a_author']."</p>
</div>";// echo out all data
}
}
?>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<!--This is the calculaor operation-->
<form method="get">
<h5>Player 1's current rating:</h5>
<input type="text" name="num1" placeholder="integers only" required></br>
<!--input the current rating of player 1 and store in num1-->
<h5>Player 2's current rating:</h5>
<input type="text" name="num2" placeholder="integers only" required></br>
<!--input the current rating of player 2 and store it in num2-->
<h5>Number of wins for player 1:</h5>
<input type="text" name="num3" placeholder="integers only" required></br>
<!--input the number of wins for player 1 and store in num3-->
<h5>Number of loss for player 1:</h5>
<input type="text" name="num4" placeholder="integers only" required></br>
<!--input number of loss for player 1 and store in num4-->
<h5>Number of wins for player 2:</h5>
<input type="text" name="num5" placeholder="integers only" required></br>
<!--input the number of wins for player 2 and store it in num5-->
<h5>Number of loss for player 2:</h5>
<input type="text" name="num6" placeholder="integers only" required></br></br>
<!--input the number of loss for player 2 and store it in num 6-->
<select name="operator">
<!--operator which the user selects the outcome of the game-->
<option>None</option>
<option>Win for player 1</option>
<option>Loss for player 1</option>
<option>Drawn</option>
</select>
<br></br>
<button type="submit" name="submit">Calculate</button></br></br>
</form>
<p>Current Rating</p>
<?php
//First I check if the button has been clicked
if (isset($_GET['submit'])) {
//Then I get all the data from the form
$result1 = $_GET['num1'];
$result2 = $_GET['num2'];
$operator = $_GET['operator'];
//Here I check which operator the user chose, and we perform the calculation
switch ($operator) {
case "None":
echo "You must select the outcome of the game and fill in all fields";
break;
//now this is an algorthium calculating the rating of the user if player 1 wins and player 2 loss
case "Win for player 1":
$result3 = 1/(1+pow(10,(($result2-$result1)/400)));
echo "Player 1's current rating: </br>";
echo $result1 + 32 * (1.0 - $result3);
echo "<br />";
echo "Player 2's current rating: </br>";
echo $result2 + 32 * ( 0.0 - $result3);
break;
//this caluclates the rating of the user if player 1 loss and player 2 wins
case "Loss for player 1":
$result3 = 1/(1+pow(10,(($result1-$result2)/400)));
echo "Player 1's current rating: </br>";
echo $result1 + 32 * ( 0.0 - $result3);
echo "<br />";
echo "Player 2's current rating: </br>";
echo $result2 + 32 * (1.0 - $result3);
break;
//this calculate the rating if both players drawn
case "Drawn":
$result3 = 1/(1+pow(10,(($result2-$result1)/400)));
echo "Player 1's current rating: </br>";
echo $result1 + 32 * ( 0.5 - $result3);
echo "<br />";
echo "Player 2's current rating: </br>";
$result_drawn = 1/(1+pow(10,(($result1-$result2)/400)));
echo $result2 + 32 * ( 0.5 - $result_drawn);
break;
default:
echo "Error, please input valid details";
break;
}
}
?>
</body>
</html>
<style>
body{
background-color:#f6f6ee;
}
</style>
\ No newline at end of file
code.php 0 → 100644
<?php
session_start(); //start the session
require_once "connection.php"; //takes the connection for Mysqli databse
$_message="";
//set message to nothing
$role="";
//set role to nothing
if(isset($_POST["btnLogin"]))
{
//gets the input for username and password
$username = $_POST["username"];
$password = $_POST["password"];
//checks the databse tblUser
$query = "SELECT * FROM tblUSer WHERE Username='$username' AND Password='$password'";
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result)){
//fetch associative array
if($row["Role"] == "Admin"){
$_SESSION['AdminUser'] = $row["Username"];
$_SESSION['role'] = $row["Role"]; // check the role of the user
header("Location: admin.php");
}
else{
//create session variables
$_SESSION['StaffUser'] = $row["Username"];
$_SESSION['role'] = $row["Role"];
header("Location: staff.php"); //brings the user to their page
}
}
}
else{
$_message = "Invalid username or password";
header("Location: M-login.php"); //error
}
}
echo $role;
?>
\ No newline at end of file
<?php
//connection to the databse
$conn = mysqli_connect("localhost", "root", "", "multuserlogin");
//unsuccessful connection
if(!$conn){
echo "connection not successfull";
}
?>
\ No newline at end of file
<?php
//require function which takes the code from other files and run it here to ensure if I need to change anything, I can do it in one file only
require "header.php";
?>
<main>
<!--
I can choose whether or not to show ANY content on our pages depending on if we are logged in or not.
-->
<?php
$message = "Please Login or Sign up first";
if (!isset($_SESSION['id'])) {
echo "<script type='text/javascript'>alert('$message');</script>"; //error message if you are not logged in
}
else if (isset($_SESSION['id'])) {
require "email.php"; //it bring to the email page
}
?>
</section>
</div>
</main>
<?php
// include the footer so that if anything requires to be changed, I only need to change it in one file only.
require "footer.php";
?>
\ No newline at end of file
<?php
require "index.php";
//require function which takes the code from other files and run it here to ensure if I need to change anything, I can do it in one file only
?>
<?php
if (isset($_POST["submit"])){ //checks if submit button is pressed
//now I create the session variables
$name = $_POST["name"];
$subject = $_POST["subject"];
$mailFrom = $_POST["mail"];
$message = $_POST["message"];
//send an email to this address
$mailTo = "haoyuyincardiffhigh@gmail.com";
//formating the email
$headers = "From Player ID: ".$name;
//formating the email and how it will be received
$txt = "Player ID: ".$name." has played against: ".$mailFrom."\n\n The outcome of the game is ".$subject.".\n\n Gameplay: \n\n".$message;
mail($mailTo, $headers, $txt);
header("Location: email.php?successful");
}
?>
\ No newline at end of file
dbh2.php 0 → 100644
<?php
//databse connection
$server = "localhost";
$username = "root";
$password = "";
$dbname = "dbphpsearch";
$conn_tournament = mysqli_connect($server, $username, $password, $dbname);
if (!$conn_tournament){
die("fail connection".mysqli_connect_error()); //eroor happens with the databse connection
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Contact staff</title>
<link rel="stylesheet" href="style-email.css"><!--Styling the webpage-->
</head>
<body>
<main>
<p>UPLOAD YOUR GAMES</p>
<form class="contact-form" action="contactform.php" method="post"><!--create a form for the user to input their gameplay-->
<input type="text" name="name" placeholder="User ID/ Username" required><!--presence check-->
<input type="text" name="mail" placeholder="Opponent ID/ Username" required><!--presence check-->
<input type="text" name="subject" placeholder="Outcome(W/L/D)" required><!--presence check-->
<textarea name="message" placeholder="Gameplay" required></textarea >
<button type="submit" name="submit">SEND MAIL</button>
<form class="home-form" action="index.php" method="post">
<button a href="index.php">Home</a></button>
</main>
</body>
</html>
\ No newline at end of file
<?php
// To make sure we don't need to create the header section of the website on multiple pages, we instead create the header HTML markup in a separate file which we then attach to the top of every HTML page on our website. In this way if we need to make a small change to our header we just need to do it in one place. This is a VERY cool feature in PHP!
require "header.php";
?>
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<link rel="stylesheet" href="style2.css"><!--stle sheet-->
</head>
<main>
<section class="events-links">
<div class="wrapper">
<h2>Recent Events</h2>
<a href="event1.php">
<div class="events-link">
<p>Altibox Norway Chess |</p><!--evetns which will be displyed on the event page, with their hyperlink-->
</div>
</a>
<a href="event2.php">
<div class="events-link">
<p>Women’s World Championship</p>
</div>
</a>
<a href="event3.php">
<div class="events-link">
<p>Cairns Cup</p>
</div>
</a>
<a href="event4.php">
<div class="events-link">
<p> European Rapid and Blitz Championship </p>
</div>
</a>
<a href="event5.php">
<div class="events-link">
<p>Russian Rapid Grand Prix Final</p>
</div>
</a>
<a href="event6.php">
<div class="events-link">
<p> Russian Cup Final</p>
</div>
</a>
<a href="event7.php">
<div class="events-link">
<p>European Youth Championships</p>
</div>
</a>
<a href="event8.php">
<div class="events-link">
<p>Winter Chess Classic</p>
</div>
</a>
</section>
</main>
</html>
<?php
// To make sure I don't need to create the header section of the website on multiple pages, we instead create the header HTML markup in a separate file which we then attach to the top of every HTML page on our website. In this way if we need to make a small change to our header we just need to do it in one place. This is a VERY cool feature in PHP!
require "footer.php";
?>
\ No newline at end of file
<?php
// To make sure we don't need to create the header section of the website on multiple pages, we instead create the header HTML markup in a separate file which we then attach to the top of every HTML page on our website. In this way if we need to make a small change to our header we just need to do it in one place. This is a VERY cool feature in PHP!
require "header.php";
?>
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style> <!--styling inside the styling tab-->
body11111 {font-family: "Times New Roman", Georgia, Serif;}
h1, h2, h3, h4, h5, h6 {
font-family: "Playfair Display";
letter-spacing: 5px;
}
img {
float: left;
padding-right:100px;
margin:15px;
padding-top:70px;
}
h1{
padding-top:70px;
}
p{
padding-top:30px;
}
</style>
<body1>
<!-- Page content -->
<div>
<!-- About Section -->
<div>
<div>
<img src="img/magnus.jpg" alt="Table Setting" width="620" height="400">
</div>
<div>
<h1>June 2020</h1><br><!--things which will be displayed inside the event page-->
<h5>June 1 – 12 | Altibox Norway Chess | Stavanger, Norway</h5>
<p>World Champion Magnus Carlsen will head the field for the 8th edition of this Norwegian super-tournament. Once again the organisers are planning a format where draws in classical chess are followed by Armageddon, while this year Vladimir Kramnik will join Judit Polgar as a commentator.</p>
<p>Fabiano Caruana spoilt Magnus Carlsen's final day by winning their match in Armageddon, but Magnus won the other 6 Armageddons he played and won the tournament by a full 3 points</p>
</div>
</div>
</body>
</html>
<?php
// To make sure we don't need to create the header section of the website on multiple pages, we instead create the header HTML markup in a separate file which we then attach to the top of every HTML page on our website. In this way if we need to make a small change to our header we just need to do it in one place. This is a VERY cool feature in PHP!
require "footer.php";
?>
\ No newline at end of file
<?php
// To make sure we don't need to create the header section of the website on multiple pages, we instead create the header HTML markup in a separate file which we then attach to the top of every HTML page on our website. In this way if we need to make a small change to our header we just need to do it in one place. This is a VERY cool feature in PHP!
require "header.php";
?>
<!--event pages which are being designed-->
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style><!--styling inside the style tab-->
body11111 {font-family: "Times New Roman", Georgia, Serif;}
h1, h2, h3, h4, h5, h6 {
font-family: "Playfair Display";
letter-spacing: 5px;
}
img {
float: left;
padding-right:100px;
margin:15px;
padding-top:70px;
}
h1{
padding-top:70px;
}
p{
padding-top:30px;
}
h5{
margin-right:15px;
}
</style>
<body1>
<!-- Page content -->
<div>
<div>
<div>
<img src="img/female_chess.jpg" alt="Table Setting" width="620" height="320">
</div>
<div>
<h1>July 2020</h1><br>
<h5>The 2020 Womens World Championship is a 12-game match featuring Chinese defending champion and womens world no. 2 Ju Wenjun and her Russian challenger Aleksandra Goryachkina, who won the 2019 Womens Candidates Tournament. The first six games of the match take place in Shanghai before the players head further east to Vladivostok for the remainder of the match.</p>
</div>
</div>
</body>
</html>
<?php
// To make sure we don't need to create the header section of the website on multiple pages, we instead create the header HTML markup in a separate file which we then attach to the top of every HTML page on our website. In this way if we need to make a small change to our header we just need to do it in one place. This is a VERY cool feature in PHP!
require "footer.php";
?>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<footer>
<ul class="footer-links-main">
<li><a href="index.php">Home</a></li> <!--design of the footer -->
<li><a href="event.php">Events</a></li>
<li><a href="about.php">About</a></li>
</ul>
<ul class="footer-links-evetns">
<li><p>Recent Events</p></li>
<li><a href="#">U12 Chess Tournament</a></li>
<li><a href="#">U17 Chess Tournament</a></li>
<li><a href="#">Welsh Winter Blitz</a></li>
<li><a href="#">4NCL Division 3 South and Division 4 South(Rounds 3-4)</a></li>
</ul>
<div class="footer-sm">
<a href="https://www.youtube.com/">
<img src="img/youtube-symbol.png" alt="youtube icon"><!--image icons-->
</a>
</div>
<div class="footer-sm">
<a href="https://twitter.com/explore">
<img src="img/twitter-logo-button.png" alt="twitter icon"><!--image icons-->
</a>
</div>
<div class="footer-sm">
<a href="https://www.facebook.com/">
<img src="img/facebook-logo-button.png" alt="facebook icon"><!--image icons-->
</a>
</div>
</footer>
</body>
</html>
<?php
// start a session which allow for us to store information as SESSION variables.
session_start();
// "require" creates an error message and stops the script. "include" creates an error and continues the script.
require "includes/dbh.inc.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="This is an example of a meta description. This will often show up in search results.">
<meta name=viewport content="width=device-width, initial-scale=1">
<title></title>
<link rel="stylesheet" href="style2.css"><!--apply style sheet-->
</head>
<body>
<header>
<a class="header-logo" href="index.php">Y-Chess</a> <!--logo design-->
<nav class="nav-header-main">
<ul>
<li><a href="index.php">Home</a></li> <!--navigation bars with buttons leading to different pages-->
<li><a href="tournament.php">Events/Tournament</a></li>
<li><a href="profile.php">Profile</a></li>
<li><a href="contact.php">Gameplay </a></li>
</ul>
</nav>
<div class="header-login">
<?php
// check if the user is logged in or not and depending on their login status, this php will display differently.
if (!isset($_SESSION['id'])) {
echo '<form action="includes/login.inc.php" method="post">
<input type="text" name="mailuid" placeholder="E-mail/Username">
<input type="password" name="pwd" placeholder="Password">
<button type="submit" name="login-submit">Login</button>
</form>
</br>
<p class="login-status">You are logged out!</p></ br></ br></ br>
<a href="signup.php" class="header-signup">Signup</a>';
}
else if (isset($_SESSION['id'])) {
echo '<form action="includes/logout.inc.php" method="post">
<button type="submit" name="login-submit">Logout</button>
</form>
<p class="login-status">WELCOME '.$_SESSION['uid'].'</p></ br></ br></ br>';
}
?>
</div>
</header>
</body>
</html>
\ No newline at end of file
<?Php
include "dbh2.php";
//database connection
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css"> <!--apple stylesheet-->
</head>
<body>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment