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
Binary file added mari batmanashvili/Capture.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mari batmanashvili/images/uk.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions mari batmanashvili/task.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Task 1</title>
</head>
<body>

<?php
$fnameErr = $lnameErr = $imageErr = "";
$fname = $lname = $img_name = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {

if (empty($_POST["fname"])) {
$fnameErr = "First Name is required";
} else {
$fname = $_POST["fname"];
if (!preg_match("/^[A-Za-z]+$/",$fname)) {
$fnameErr = "Only alphabets are allowed";
}
}

if (empty($_POST["lname"])) {
$lnameErr = "Last Name is required";
} else {
$lname = $_POST["lname"];
if (!preg_match("/^[A-Za-z]+$/",$lname)) {
$lnameErr = "Only alphabets are allowed";
}
}

if ($_FILES['image']['name'] == "") {
$imageErr = "Image is required";
} else {
$img_name = $_FILES['image']['name'];
$img_type = $_FILES['image']['type'];
$img_tmp_name = $_FILES['image']['tmp_name'];
move_uploaded_file($img_tmp_name, "images/$img_name");
}

}

?>

<form method="post" action="task.php" enctype="multipart/form-data">
First Name:
<input type="text" name="fname">
<span><?php echo $fnameErr; ?> </span>
<br><br>
Last Name:
<input type="text" name="lname">
<span><?php echo $lnameErr; ?> </span>
<br><br>
<input type="file" name="image">
<br><br>
<input type="submit" name="submit" value="Submit">
<br><br>
</form>

<?php
if(isset($_POST['submit'])) {
if($fnameErr == "" && $lnameErr == "" && $imageErr == "") {
echo "<h2>Hello </h2>";
echo "<h3>First Name: " .$fname.'</h3>';
echo "<br>";
echo "<h3>Last Name: " .$lname.'</h3>';
echo "<br>";
?>
<img src="images/<?php echo $img_name ?>" alt="">
<?php
} else {
echo "<h3><b>Please fill in all the fields.</b></h3>";
}
}
?>

</body>
</html>
52 changes: 52 additions & 0 deletions mari batmanashvili/task2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
body{
background-color: rgb(151, 157, 158);
box-sizing: border-box;
margin: 0;
padding: 0;
background-image: url("Capture.PNG");
background-repeat: no-repeat;
background-size: 900px;
background-color: black;
background-size: 100%;


}
.Name_Control{
width: 94%;
height: 50px;
border: 4px solid blue;
}
.submit{
height: 45px;
width: 200px;
color: rgb(10, 10, 10);
margin-left: 40%;
border: none;
background-color: rgb(255, 255, 255);
cursor: pointer;
}
.first_repo{
display: flex;
justify-content: space-around;
color: white;
background-color: rgb(7, 9, 100);
align-items: center;
}
.picture{
height: 200px;
width: 200px;
}
.folo{
height: 100px;
width: 100%;
background-color: rgb(229, 255, 0);
color: white;
display: flex;
align-items: center;
justify-content: center;
}
.Pics-of-Followers{
display: flex;


}
110 changes: 110 additions & 0 deletions mari batmanashvili/task2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="task2.css">
<title>Document</title>
</head>
<body>
<?php
$manipulation=0;
$follower_manipulation=0;

if(isset($_POST['submit']))
{
if(empty($_POST['name']))
{
$eror="<h1 style ='color:green'>* search is empty </h1>";
echo $eror;
}else{
$name=$_POST['name'];
$manipulation=1;
}
}
//User Search
$headers=[
'User-Agent: Generate new token',
'Authorization: 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'
];
if($manipulation==1)
{
$ch =curl_init("https://api.github.com/users/$name");
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$responce=curl_exec($ch);
curl_close($ch);
$data=json_decode($responce,true);
$imge= $data["avatar_url"];
$saxeli=$data['name'];
$followers=$data['followers'];
$user=$data['login'];

if($followers > 0){
$follower_manipulation=1;
}
else{
$follower_manipulation=2;
}
}

?>


<form class="forms" action="task2.php" method="post" enctype="multipart/form-data">
<input class="Name_Control" type="text" name="name" placeholder="Enter the Search name"><br>
<input class="submit" type="submit" name="submit" value="Search">
</form>
<?php
//User Information
if($manipulation==1)
{


$info=
"<div class='first_repo'>
<img class='picture' src='$imge' alt=''>
<h1>name : $saxeli </h1>
<h1 style='margin-left: 200px'>Username : $user </h1>
<h1 style='margin-left: 200px'>Followers : $followers</h1>
</div>
<div class='folo'><h2 style='margin-right: 5%;'>Folowers</h2></div>
";

echo $info;
}

if($follower_manipulation==1)
{
$ch =curl_init("https://api.github.com/users/$name/followers");
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$responce=curl_exec($ch);
curl_close($ch);
$data=json_decode($responce,true);
foreach($data as $repositori)
{
$suraTi= $repositori['avatar_url'];
$id= $repositori['id'];
$login= $repositori['login'];
$element = "

<div class='Pics-of-Followers'>
<img style='height:50px ; width:50px' src='$suraTi' alt=''>
<p style='margin-left: 100px'>ID : $id</p>
<p style='margin-left: 100px'>USERNAME : $login</p>
</div>
";'<br>';
echo $element;
}
}
if( $follower_manipulation==2){
$no_follovers= "<div class='folo'><p style='margin-right: 5%;'>User hasnot any Followers </p></div>";
echo $no_follovers;
}
?>
<style>
</style>
</body>
</html>