-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpets_new.php
More file actions
83 lines (67 loc) · 2.16 KB
/
pets_new.php
File metadata and controls
83 lines (67 loc) · 2.16 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
require 'lib/functions.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['name'])) {
$name = $_POST['name'];
} else {
$name = 'A dog without a name';
}
if (isset($_POST['breed'])) {
$breed = $_POST['breed'];
} else {
$breed = '';
}
if (isset($_POST['weight'])) {
$weight = $_POST['weight'];
} else {
$weight = '';
}
if (isset($_POST['bio'])) {
$bio = $_POST['bio'];
} else {
$bio = '';
}
$pets = get_pets();
$newPet = array(
'name' => $name,
'breed' => $breed,
'weight' => $weight,
'bio' => $bio,
'image' => '',
'age' => '',
);
$pets[] = $newPet;
save_pets($pets);
header('Location: /');
die;
}
?>
<?php require 'layout/header.php'; ?>
<div class="container">
<div class="row">
<div class="col-xs-6">
<h1>Add your Pet! Squirrel!</h1>
<form action="/pets_new.php" method="POST">
<div class="form-group">
<label for="pet-name" class="control-label">Pet Name</label>
<input type="text" name="name" id="pet-name" class="form-control" />
</div>
<div class="form-group">
<label for="pet-breed" class="control-label">Breed</label>
<input type="text" name="breed" id="pet-breed" class="form-control" />
</div>
<div class="form-group">
<label for="pet-weight" class="control-label">Weight (lbs)</label>
<input type="number" name="weight" id="pet-weight" class="form-control" />
</div>
<div class="form-group">
<label for="pet-bio" class="control-label">Pet Bio</label>
<textarea name="bio" id="pet-bio" class="form-control"></textarea>
</div>
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-heart"></span> Add</button>
</form>
</div>
</div>
</div>
Squirrel!
<?php require 'layout/footer.php'; ?>