-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhitter.edit.php
More file actions
63 lines (58 loc) · 2.34 KB
/
hitter.edit.php
File metadata and controls
63 lines (58 loc) · 2.34 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
55
56
57
58
59
60
61
62
63
<?php
namespace Pmeth\RBI;
include('bootstrap.php');
if (empty($_GET['offset'])) {
die("Sorry, invalid offset. <a href='index.php'>Return to Home</a>");
}
$offset = $_GET['offset'];
$mapper = new HitterROMMapper($myrom);
$myhitter = $mapper->get($offset);
if (!empty($_POST['submit'])) {
// this has to be first for it to do anything
$myhitter->setAcceptAbnormal(isset($_POST['acceptabnormal']) && $_POST['acceptabnormal'] == 'true');
$myhitter->setName($_POST['name']);
$myhitter->setPosition($_POST['pos']);
$myhitter->setBats($_POST['bats']);
$myhitter->setAverage($_POST['avg']);
$myhitter->setHomeruns($_POST['hr']);
$myhitter->setPower($_POST['power']);
$myhitter->setContact($_POST['contact']);
$myhitter->setSpeed($_POST['speed']);
if ($mapper->validate($myhitter)) {
$mapper->save($myhitter);
header("Location: hitter.view.php?offset=$offset&message=Player updated");
} else {
echo "Some fields did not validate:<br>";
echo $myhitter->getError();
}
}
$hitterdetails = '
Hitter:<br />
<form action="' . $_SERVER['PHP_SELF'] . '?offset=' . $offset . '" method="post">
Team: ' . $myhitter->getTeam()->getName() . '<br />
Offset: ' . $myhitter->getOffset() . '<br />
Lineup #: ' . $myhitter->getLineupNumber() . '<br />
Type: ' . $myhitter->getType() . '<br />
Name: <input name="name" type="text" value="' . $myhitter->getName() . '" /><br />
Pos: <input name="pos" type="text" value="' . $myhitter->getPosition() . '" /><br />
Bats: <input name="bats" type="text" value="' . $myhitter->getBats() . '" /><br />
Avg: <input name="avg" type="text" value="' . $myhitter->getAverage() . '" /><br />
HR: <input name="hr" type="text" value="' . $myhitter->getHomeruns() . '" /><br />
Power: <input name="power" type="text" value="' . $myhitter->getPower() . '" /><br />
Contact: <input name="contact" type="text" value="' . $myhitter->getContact() . '" /><br />
Speed: <input name="speed" type="text" value="' . $myhitter->getSpeed() . '" /><br />
Accept Abnormal: <input name="acceptabnormal" type="checkbox" value="true" /><br />
<input type="submit" name="submit" value="Save" /><br />
';
echo "<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<title></title>
</head>
<body>
<div class='menu'><a href='player.list.php'>Return to List</a></div>
$hitterdetails
</body>
</html>
";