Skip to content

Commit

Permalink
Feature Update
Browse files Browse the repository at this point in the history
Added some features to log back onto the Tournament Data to access Registration Path. Also added a PersonalJob_Edit.php that would allow an end user who has no knowledge of SQL and Queries to manage and edit the database. Features such as Dropping a Team, Adding Names, Editing Names, Dropping Names is included in this current version.
  • Loading branch information
SahasR authored Feb 11, 2020
1 parent aa3eb6c commit aeb5375
Show file tree
Hide file tree
Showing 13 changed files with 449 additions and 16 deletions.
183 changes: 183 additions & 0 deletions Index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<?php
session_start();

$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "dbtournament";
$booleanValidate = "false";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
die("Connection Failed: ". $conn->connect_error);
}

if (isset($_POST["btnCont"])) {
$TournamentName = $_POST["txtCont"];
$sql = "SELECT * FROM savedata";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result)) {
$NumBreak = $row['NumBreak'];
$NumRounds = $row['NumRounds'];
$NumSeed = $row['NumSeed'];
$RoundNumber= $row['RoundNumber'];
// $TournamentName = $row['TournamentName'];
}
$_SESSION["NumBreak"] = $NumBreak;
$_SESSION["NumRounds"] = $NumRounds;
$_SESSION["NumSeed"] = $NumSeed;
$_SESSION["TName"] = $TournamentName;
// echo "NumBreak: $NumBreak<br>";
// echo "NumSeed: $NumSeed<br>";
// echo "NumRounds: $NumRounds<br>";
if ($RoundNumber > $NumSeed) {
header("Location:PersonalJob_PowerRound");
}
else {
header("Location:PersonalJob_SeedRound");
}
}

if (isset($_POST["btnStart"])) {
$NumBreak = $_POST["txtBreak"] * 1;
$NumSeed = $_POST["txtNumSeeds"];
$TournamentName = $_POST["txtEnterTName"];
$TournamentName = str_replace(' ', '', $TournamentName);
$NumRounds = $_POST["txtNumRounds"];
$Try = ValidatePage($NumBreak, $NumSeed, $TournamentName, $NumRounds);
//echo "$booleanValidate";
if ($Try == "true") {
$_SESSION["NumBreak"] = $NumBreak;
$_SESSION["NumRounds"] = $NumRounds;
$_SESSION["NumSeed"] = $NumSeed;
$_SESSION["TName"] = $TournamentName;
$sql = "CREATE TABLE $TournamentName (
MemberName varchar(255),
TeamName varchar(255),
SchoolName varchar(255),
Novice boolean,
FoodPreference varchar(20),
ContactDetails varchar(25)
);";
$result = $conn->query($sql);
$sql = "CREATE TABLE savedata (
NumBreak FLOAT,
NumRounds FLOAT,
NumSeed FLOAT,
TournamentName varchar(255),
RoundNumber FLOAT
)";
$result = $conn->query($sql);
$sql = "INSERT INTO savedata (NumBreak, NumRounds, NumSeed,TournamentName)
VALUES ($NumBreak, $NumRounds, $NumSeed, '$TournamentName')";
$result = $conn->query($sql);

header("Location: PersonalJob_Reg.php");

}
else {
echo "Some data is wrong";
}

}

function ValidatePage($pNumBreak, $pNumSeed, $pTournamentName, $pNumRounds) {
if ($pNumBreak <> "" && $pNumSeed <> "" && $pTournamentName <> "" && $pNumRounds <> "" ) {
if ($pNumBreak%2 == 0 ) {
//echo "$pNumBreak";
//echo "$pNumSeed";
//echo "$pTournamentName";
//echo "$pNumRounds";
$booleanValidate = "true";
return "$booleanValidate";
//echo "$booleanValidate";
}
}
}



?>

<!DOCTYPE html>
<html>
<head>
<title>WebBasedDebate</title>
<script type="text/javascript">
$(document).keypress(
function(event){
if (event.which == '13') {
event.preventDefault();
}
});
</script>
</head>
<body>
<div id="divStartUp" style="width: 30%; height: 30%; text-align: center; position:absolute; left:0; right:0; margin-left:auto; margin-right:auto; display: inline-block;">
<form method="POST">
<table>
<tr>
<td>
Enter Tournament Name:
</td>
<td>
<input type="text" name="txtEnterTName" id="txtEnterTName">
</td>
</tr>
<tr>
<td>
Number of Prelimanry Rounds:
</td>
<td>
<input type="text" name="txtNumRounds" id="txtNumRounds">
</td>
</tr>
<tr>
<td>
Number of Seeded Rounds:
</td>
<td>
<input type="text" name="txtNumSeeds" id="txtNumSeeds">
</td>
</tr>
<tr>
<td>
Number of Teams Breaking:
</td>
<td>
<input type="text" name="txtBreak" id="txtBreak">
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="btnStart" id="btnStart" value="Create Tournament">
</td>
</tr>
</table>
</div>
<div id="divBoast" style="float: right; background-color: cyan; width: 20%; text-align: center;">No Rights Reserved by Sahas Gunasekara cause Communism Comrades.</div>
<div id="divContinue" style="float: left; background-color: salmon; text-align: center;">
If you are continuing the tournament:
<table>
<tr>
<td>
Enter Tourney Name:
</td>
<td>
<input type="text" name="txtCont" id="txtCont">
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" name="btnCont" id="btnCont" value="Continue Tabbing">
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
122 changes: 122 additions & 0 deletions PersonalJob_Edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php
session_start();

$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "dbtournament";

$TName = $_SESSION["TName"];


$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
die("Connection Failed: ". $conn->connect_error);
};

if (isset($_POST["btnRename"])) {
$Name = $_POST["txtName"];
$NewName = $_POST["txtNewName"];
$sql = "UPDATE $TName SET MemberName='$NewName' WHERE MemberName='$Name';";
// echo "$sql";
$result = $conn->query($sql);
}

if (isset($_POST["btnAddDebator"])) {
$Name = $_POST["txtNewDebator"];
$TeamName = $_POST["txtTeamName"];
$School = $_POST["txtSchoolName"];
$sql = "INSERT INTO $TName (MemberName, TeamName, SchoolName) VALUES ('$Name','$TeamName','$School');";
$result = $conn->query($sql);
}

if (isset($_POST["btnRemoveDebator"])) {
$Name = $_POST["txtRemoveDebator"];
$sql = "DELETE FROM $TName WHERE MemberName='$Name'";
$result = $conn->query($sql);
}

if (isset($_POST["btnDropTeam"])) {
$TeamName = $_POST["txtDropTeamName"];
$sql = "DELETE FROM $TName WHERE TeamName='$TeamName'";
$result = $conn->query($sql);
$sql = "DELETE FROM wins WHERE TeamName='$TeamName'";
$result = $conn->query($sql);
}


?>
<!DOCTYPE html>
<html>
<head>
<title>Admin Page!</title>
</head>
<body>
<form method="POST">
<table>
<tr>
<td>
Replace Name:
</td>
<td>
<input type="text" name="txtName" id="txtName">
</td>
<td>
With:
</td>
<td>
<input type="text" name="txtNewName" id="txtNewName">
</td>
<td>
<input type="submit" name="btnRename" id="btnRename" value="Rename">
</td>
</tr>
<tr>
<td>
Add a Debator to a Team:
</td>
<td>
<input type="text" name="txtNewDebator" id="txtNewDebator">
</td>
<td>
Team Name:
</td>
<td>
<input type="text" name="txtTeamName" id="txtTeamName">
</td>
<td>
School Name:
</td>
<td>
<input type="text" name="txtSchoolName" id="txtSchoolName">
</td>
<td>
<input type="submit" name="btnAddDebator" id="btnAddDebator" value="Add Debator">
</td>
</tr>
<td>
Remove a Debator to a Team:
</td>
<td>
<input type="text" name="txtRemoveDebator" id="txtRemoveDebator">
</td>
<td>
<input type="submit" name="btnRemoveDebator" id="btnRemoveDebator" value="Remove Debator">
</td>
</tr>
<tr>
<td>
Drop a Team:
</td>
<td>
<input type="text" name="txtDropTeamName" id="txtDropTeamName">
</td>
<td>
<input type="submit" name="btnDropTeam" id="btnDropTeam" value="Drop Team">
</td>
</tr>
</table>
</form>
</body>
</html>
2 changes: 1 addition & 1 deletion PersonalJob_Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

$TName = $_SESSION["TName"];
//export.php
$connect = mysqli_connect("localhost", "root", "", "dbtournament");
$connect = mysqli_connect("localhost", "root", "password", "dbtournament");
$output = '';
if(isset($_POST["export"]))
{
Expand Down
2 changes: 1 addition & 1 deletion PersonalJob_Export1.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

session_start();
$connect = mysqli_connect("localhost", "root", "", "dbtournament");
$connect = mysqli_connect("localhost", "root", "password", "dbtournament");
$TName = $_SESSION["TName"];
$sql = "SELECT * FROM $TName";
$result = mysqli_query($connect, $sql);
Expand Down
2 changes: 1 addition & 1 deletion PersonalJob_Export2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
session_start();
$TName = $_SESSION["TName"];
//export.php
$connect = mysqli_connect("localhost", "root", "", "dbtournament");
$connect = mysqli_connect("localhost", "root", "password", "dbtournament");
$output = '';
if(isset($_POST["export"]))
{
Expand Down
2 changes: 1 addition & 1 deletion PersonalJob_Finished.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
session_start();
$TName = $_SESSION["TName"];
//export.php
$connect = mysqli_connect("localhost", "root", "", "dbtournament");
$connect = mysqli_connect("localhost", "root", "password", "dbtournament");
$sql = "SELECT * FROM savedata";
$result = mysqli_query($connect, $sql);
while($row = mysqli_fetch_array($result)) {
Expand Down
Loading

0 comments on commit aeb5375

Please sign in to comment.