Universiti Teknologi Mara Test 2
Universiti Teknologi Mara Test 2
Universiti Teknologi Mara Test 2
STUDENT ID : 2019593691
GROUP CS2644B2
Instruction:
Write a very simple Dota registration system using HTML and PHP. The incomplete
code/query for each page has been provided. What you need to do is to fill in the
blanks with a correct code. You will be assessed based on the FUNCTIONALITY of the
system. WEB DESIGN IS NOT GOING TO BE ASSESSED.
What to submit?
1. This question sheets with completed answers
2. Database. Print screen each table structure from the PHPMyAdmin.
3. All HTML/PHP pages.
4. Print screen for each page in the website
How to submit?
1. Create a folder with your FULL NAME AS FOLDER NAME
2. Include all documents (PHP, screencaps, etc) in the folder
3. Zip the folder and submit the zipped folder in the TEST 2 in GOOGLE CLASSROOM.
4. Make sure you click TURN IT IN once you have uploaded the folder
5. No late submission. The test is due at 4.30pm on 08 December 2019
//login.php 6 marks
<html>
<body>
< form name="login" action ="loginps.php"_POST ">
_Hhhybedujxs/U.Ymethod="_
<h1>Log-in</h1><br>
Username :
<input name="username" type=" text " required><br>
Password :
<input name="password" type=" text " required><br>
<input type="submit " name="Login" value="login">
</form>
</body>
</html>
//dbconn.php 5 marks
<?php
$dbconn =mysqli_connect(' localhost ', 'root','123','dotadb');
if (!$dbconn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
//loginps.php 8 marks
<?php
include("dbconn.php");
if(mysqli_num_rows( $query)==1){
echo "
<script>alert('Successfully Login');
location.href = \"view.php\";</script>
";
}else{
echo "
<script>alert('Wrong Password and Username');
location.href = \"login.php\";</script>
";
}
?>
CONFIDENTIAL 2 CS/DEC 2019/CSC443
//view.php 5 marks
<?php
include("dbconn.php");
$sql = "SELECT team_id, team_name FROM team ";
$query = mysqli_query($dbconn, $sql );
$num = mysqli_num_rows($query);
if($num>0){
echo
"
<table>
<tr>
<th>No</th>
<th>Team Name</th>
</tr>
";
$i=1;
while($row=mysqli_fetch_assoc( $query )
){
echo
"
<tr>
<th>$i</th>
<th><a
href=viewTeam.php?team_id=".$row[' team_id ].">".$row['team_nam
e']."</a></ th>
</tr>
";
$i++;
}
}
//registerteam.php 2 marks
<html>
<body>
<form name="login" action="registerteamps.php"method="POST ">
<h1 align="center">Register Team</h1>
<br>
//registerteamps.php 13 marks
<?php
include ("dbconn.php");
if($query){
$sql2 ="SELECT team_id FROM team where team_name = '$team_name '";
$query2 = mysqli_query($dbconn, $sql2);
while( $row= mysqli_fetch_assoc($query2))
{
$team_id = $row[' team_id '];
}
}
?>
<html>
<body>
<form name="register" action="registermemberps.php" method="post">
Member 1 :<input type="text" name="name1 " required><br>
IC :<input type="text" name="ic1" required><br>
Address :<input type="text" name="address1" required><br>
Rank:
<select name="rank1">
<option value="Archon">Archon</option>
<option value="Legend">Legend</option>
<option value="Ancient">Ancient</option>
<option value="Divine">Divine</option>
<option value="Immortal">Immortal</option>
</select><br>
Phone :<input type="text" name="phone1" required><br><br><br>
Rank:
<select name="rank3">
<option value="Archon">Archon</option>
<option value="Legend">Legend</option>
<option value="Ancient">Ancient</option>
<option value="Divine">Divine</option>
<option value="Immortal">Immortal</option>
</select><br>
Phone :<input type="text" name="phone3" required><br><br><br>
//registermemberps.php 11 marks
<?php
include("dbconn.php");
$team_id = $_POST['team_id'];
$name1=$_POST['name1'];
$ic1=$_POST['ic1'];
$address1 =$_POST['address1'];
$rank1=$_POST['rank1'];
$phone1=$_POST[' '];
$sql1= "INSERT INTO member(member_name, member_ic, member_address,
member_rank, member_phone,team_id)
VALUES ('$name1', '$ic1', '$address'rank1 ', '$phone1', '$team_id')";
$query1= mysqli_query($dbconn, $sql1 );
$name2=$_POST['name2'];
$ic2=$_POST['ic2'];
$address2=$_POST['address2'];
$rank2=$_POST['rank2'];
$phone2=$_POST['phone2'];
$sql2 = "INSERT INTO member(member_name, member_ic,
member_address, member_rank, member_phone, team_id)
(' ', '$ic2', '$address2', '$rank2', '$phone2', '$team_id')";
$query2= mysqli_query($dbconn, $sql2);
$name3=$_POST['name3'];
$ic3=$_POST['ic3'];
$address3=$_POST['address3'];
$rank3=$_POST['rank3'];
$phone3=$_POST['phone3'];
$name4=$_POST['name4'];
$ic4=$_POST[' ic4 '];
$address4=$_POST['address4'];
$rank4=$_POST['rank4'];
$phone4=$_POST['phone4'];
$name5=$_POST['name5'];
$ic5=$_POST['ic5'];
$address5=$_POST['address5'];
CONFIDENTIAL 2 CS/DEC 2019/CSC443
$rank5=$_POST['rank5'];
$phone5=$_POST['phone5'];
$sql5= "INSERT INTO member(member_name, member_ic, member_address,
member_rank, member_phone, team_id)
VALUES ('$name5', '$ic5', '$address5', '$rank5', '$phone5',
'$team_id')";
$query5= mysqli_query($dbconn , $sql5);