-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraceResults.php
More file actions
54 lines (43 loc) · 1.51 KB
/
raceResults.php
File metadata and controls
54 lines (43 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!-- Q7 -->
<?php
$title="Add Race Results";
require_once('head.php');
echo "<body>";
echo"<h2> Add Race Results </h2>";
if(empty($_POST['memberID']))
echo "<p>You must enter a memberID</p>";
else if(empty($_POST['raceID']))
echo "<p>You must enter a raceID</p>";
else if(empty($_POST['position']))
echo "<p>You must enter a position</p>";
else{
$memberID =$_POST['memberID'];
$raceID =$_POST['raceID'];
$position =$_POST['position'];
$conn = mysqli_connect('localhost', 'root', 'password', 'canary');
$query = "SELECT memberID FROM member WHERE '$memberID' = member.memberID";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($result);
$memberID = $row['memberID'];
$query = "SELECT raceID FROM race WHERE '$raceID' = race.raceID";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($result);
$raceID = $row['raceID'];
if(!$memberID)
echo "<p> Member does not exist</p>";
else if(!$raceID)
echo "<p> Race does not exist</p>";
else{
$query = "UPDATE competitor SET position = '$position' WHERE memberID = '$memberID' AND raceID = '$raceID'";
$result = mysqli_query($conn, $query);
echo "<p> MemberID: $memberID </p>";
echo "<p> RaceID: $raceID </p>";
echo "<p> Position: $position </p>";
mysqli_close($conn);
}
}
echo "<a href='index.php'> Back To Index </a>";
require_once('footer.php');
echo "</body>";
echo "</html>";
?>