-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
37 lines (31 loc) · 826 Bytes
/
index.php
File metadata and controls
37 lines (31 loc) · 826 Bytes
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
<?php
if(isset($_GET['name']) && !empty($_GET['name'])) {
$response = file_get_contents('https://api.agify.io?name=' . urlencode($_GET['name']));
$data = json_decode($response, true);
$age = $data['age'];
}
//display the first name of the user
// echo $data['results'][0]['name']['first'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Testing</title>
</head>
<body>
<h1>Your are
<?php
if(isset($age)) {
echo "{$age} years old";
}
?>
</h1>
<form action="">
<label for="">Name</label>
<input type="text" name="name" id="" placeholder="Enter your name">
<button type="submit">Submit</button>
</form>
</body>
</html>