-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditDog.php
197 lines (162 loc) · 7.32 KB
/
editDog.php
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
// include the configs
require_once("config.php");
// load the login class
require_once("Login/classes/Login.php");
// create a login object.
$login = new Login();
// ... ask if we are logged in here:
if ($login->isUserLoggedIn() == true) {
// the user is logged in...
// include("Login/views/logged_in.php");
} else {
// the user is not logged in...
header( 'Location: /manage/Login' ) ;
}
?>
<?php
// Create connection
$conn = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM dogs where id = '" . $_GET['id'] . "'";
$result = $conn->query($sql);
$row = mysqli_fetch_assoc($result);
?>
<!DOCTYPE html>
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hairyhounz Adoption Database</title>
<head>
<meta charset=utf-8>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/modifyDog.js"></script>
<link rel="stylesheet" type="text/css" href="//bootswatch.com/4/darkly/bootstrap.min.css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<div class="navbar navbar-expand-lg fixed-top navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="#"><?php echo $charityName ?> Adoption Database</a>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> ☰
</button>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="nav-item"><a href="/manage/" class="nav-link">Add Dog</a>
</li>
<li class="active nav-item"><a href="/manage/editDogList.php" class="nav-link">Edit Dogs</a>
</li>
</ul>
<!--Login dropdown menu -->
<ul class="nav navbar-nav nav navbar-nav ml-auto">
<li class="dropdown nav-item"> <a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown">Welcome <b><?php echo $_SESSION['user_name']; ?></b> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="dropdown-item"><a href="/manage/Login/register.php">New User</a>
</li>
<li class="dropdown-item"><a href="index.php?logout">Log Out</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<!-- Success Modal -->
<div class="fade modal" id="success">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title"><?php echo $row["name"]; ?> Updated</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<strong><p>Sweet!</strong> Keep thoses updates coming.</p>
</div>
</div>
</div>
</div>
<!-- Delete Modal -->
<div class="fade modal" id="delete">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Delete <?php echo $row["name"]; ?></h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<p>Are you sure you want to delete <strong><?php echo $row["name"]; ?>?</strong></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a class="btn btn-danger" href="lib/delete.php?id=<?php echo $_GET['id'] ?>" role="button">Delete</a>
</div>
</div>
</div>
</div>
<div class="page-header" id="banner">
<div>
<h1>Editing <?php echo $row["name"]; ?></h1>
</div>
</div>
<form id="form">
<input type="hidden" id="id" name="id" value="<?php echo $row["id"]; ?>">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter name" required value="<?php echo $row["name"]; ?>" />
</div>
<div class="form-group">
<label for="email">Breed</label>
<input type="text" class="form-control" id="breed" name="breed" placeholder="Enter breed" required value="<?php echo $row["breed"]; ?>" />
</div>
<div class="form-group">
<label for="email">Age</label>
<input type="text" class="form-control" id="age" name="age" placeholder="Enter age" required value="<?php echo $row["age"]; ?>" />
</div>
<div class="form-group">
<label for="sex">Sex</label>
<select class="form-control" name="sex" id="sex" value="<?php echo $row["sex"]; ?>">
<option value="Male" <?php if ($row["sex"] == "Male") { echo "selected"; } ?>>Male</option>
<option value="Female" <?php if ($row["sex"] == "Female") { echo "selected"; } ?>>Female</option>
</select>
</div>
<div class="form-group">
<label for="email">Location</label>
<input type="text" class="form-control" id="location" name="location" placeholder="Enter location" required value="<?php echo $row["location"]; ?>" />
</div>
<div class="form-group">
<label for="email">Short Description</label>
<input type="text" class="form-control" id="short_description" name="short_description" placeholder="Breif description" required value="<?php echo $row["short_description"]; ?>" />
</div>
<div class="form-group">
<label for="email">Long Description</label>
<textarea class="form-control rounded-0" id="long_description" name="long_description" placeholder="Detailed description" rows="3"><?php echo $row["long_description"]; ?></textarea>
</div>
<div class="form-group">
<label for="adopted">Adopted</label>
<select class="form-control" name="adopted" id="adopted" value="<?php echo $row["adopted"]; ?>">
<option value="no" <?php if ($row["adopted"] == "no") { echo "selected"; } ?>>Available</option>
<option value="yes" <?php if ($row["adopted"] == "yes") { echo "selected"; } ?>>Adopted</option>
</select>
</div>
<div id="preview"><img src="<?php echo $row["image"]; ?>" /></div><br>
<input class="btn btn-success" type="submit" value="Update">
<button onclick="goBack()" type="button" class="btn btn-info">Cancel</button>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#delete">Delete</button>
</form>
<div id="err"></div>
<hr>
<script>
function goBack() {
window.history.back();
}
</script>
</body>
</html>