Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions davit_gvelesiani/challenge1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">

<title>Challenge #1</title>
</head>
<body>
<?php if (empty($_POST)): ?>
<form method="POST" enctype="multipart/form-data">
<input type="text" name="firstName" placeholder="First name">
<input type="text" name="lastName" placeholder="Last name">
<input type="file" name="image" />
<input type="submit" name="submit" />
</form>
<?php else: ?>

<?php
if(isset($_POST['submit'])){

$img_name=$_FILES['image']['name'];
$tmp_img_name=$_FILES['image']['tmp_name'];
move_uploaded_file($tmp_img_name,$img_name);

echo "<img src='./$img_name' />";
}
?>

<?php
if($_POST['firstName'] && $_POST['lastName']){
if(ctype_alpha($_POST['firstName']) && ctype_alpha($_POST['lastName'])){
print "<h1>Username: " . $_POST['firstName'] . " " . $_POST['lastName'] . "</h1";
}else{
echo "only alphabet characters required!";
}
}
?>

</body>
</html>
72 changes: 72 additions & 0 deletions davit_gvelesiani/challenge2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Challenge #2</title>
</head>
<body>

<form method="POST">
<input type="text" name="userName" placeholder="user name">
</br>
<input type="checkbox" name="followers">followers</input>
<input type="checkbox" name="repos">repositories</input>
<input type="submit" name="submit" />
</form>


<?php
if(isset($_POST['submit'])){
$userName=$_POST['userName'];
$repos_url="https://api.github.com/users/$userName/repos";
$repos_param=[
'http' => [
'method' => 'GET',
'header' => [
'User-Agent: PHP'
]
]
];

$repos_json = file_get_contents($repos_url, false, stream_context_create($repos_param));
$repos_data = json_decode($repos_json, false);

echo "<h1>Repos:</h1>";

if($_POST['repos']){
foreach ($repos_data as $user) {
echo "name: ".$user->name;
echo "<br />";
echo "<a href='$user->html_url'>Click here to view</a>";
echo "<br /> <br />";
}
}


$followers_url="https://api.github.com/users/$userName/followers";
$followers_param=[
'http' => [
'method' => 'GET',
'header' => [
'User-Agent: PHP'
]
]
];

$followers_json = file_get_contents($followers_url, false, stream_context_create($followers_param));
$followers_data = json_decode($followers_json, false);

echo "<h1>Followers:</h1>";

if($_POST['followers']){
foreach ($followers_data as $user) {
echo "name: ".$user->login;
echo "<br />";
echo "<a href='$user->html_url'><img src='$user->avatar_url'/></a>";
echo "<br /> <br />";
}
}
}
?>

</html>