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
3 changes: 3 additions & 0 deletions giorgi_durglishvili/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
</div>
</body>
</html>
11 changes: 11 additions & 0 deletions giorgi_durglishvili/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!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>Week 1</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="wrapper">
8 changes: 8 additions & 0 deletions giorgi_durglishvili/includes/logout.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
session_start();
$file_name = $_SESSION['file_name'];
unlink("../$file_name");
session_unset();
session_destroy();
header('location: ../index.php');
exit();
45 changes: 45 additions & 0 deletions giorgi_durglishvili/includes/upload.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
if(isset($_POST['submit'])){
$allowed_ext = ['png','jpg','jpeg','gif','svg'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];

if(!isset($fname) || !isset($lname) || empty($_FILES['upload']['name'])){
header('location: ../index.php?error=emtyinput');
exit();
}

if(!preg_match("/^[a-zA-Z]*$/",$fname)||!preg_match("/^[a-zA-Z]*$/",$lname)){
header('location: ../index.php?error=invalidinput');
exit();
}

$file_name = $_FILES['upload']['name'];
$file_size = $_FILES['upload']['size'];
$file_tmp = $_FILES['upload']['tmp_name'];

$target_dir = "../$file_name";

$file_ext = explode('.',$file_name);
$file_ext = strtolower(end($file_ext));

if(!in_array($file_ext,$allowed_ext)){
header('location: ../index.php?error=invalidfile');
exit();
}
if($file_size >= 1300000){
header('location: ../index.php?error=largefile');
exit();
}
move_uploaded_file($file_tmp,$target_dir);
session_start();
$_SESSION['fname'] = $fname;
$_SESSION['lname'] = $lname;
$_SESSION['file_name'] = $file_name;
header('location: ../profile.php');
exit();

}else{
header('location: ../index.php');
exit();
}
63 changes: 63 additions & 0 deletions giorgi_durglishvili/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.wrapper {
display: grid;
place-content: center;
min-height: 100vh;
background-color: #ccc;
}

form {
background-color: white;
padding: 1.5rem;
border-radius: 7px;
width: 450px;
max-width: 90vw;
}
.input-wrapper {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.input-wrapper input {
margin-bottom: 1rem;
padding: 0.3rem 0.6rem;
outline: none;
}
.button {
padding: 0.5rem 0.7rem;
background-color: rgb(32, 32, 32);
color: white;
border: none;
border-radius: 7px;
border: 1px solid rgb(32, 32, 32);
max-width: max-content;
transition: 0.3s;
}
.button:hover {
background-color: white;
color: rgb(32, 32, 32);
cursor: pointer;
}
.error {
margin-bottom: 1rem;
color: red;
}
.profile-component {
font-size: 2rem;
gap: 1rem;
width: 550px;
max-width: 90vw;
margin-top: 1rem;
}
.profile-component img {
width: 100%;
object-fit: cover;
}
a {
text-decoration: none;
max-width: max-content;
}
38 changes: 38 additions & 0 deletions giorgi_durglishvili/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php include 'header.php' ?>

<form action="includes/upload.inc.php" method="POST" enctype="multipart/form-data">
<?php
if(isset($_GET['error'])){
switch($_GET['error']){
case 'emtyinput':
echo "<p class='error'>Fill in all the fields!</p>";
break;
case 'invalidinput':
echo "<p class='error'>Incorrect name or email!</p>";
break;
case 'invalidfile':
echo "<p class='error'>Incorrect type of file!</p>";
break;
case 'largefile':
echo "<p class='error'>File is too large!</p>";
break;
}
}
?>
<div class="input-wrapper">
<label for="name">First Name</label>
<input type="text" name="fname" placeholder="First Name...">
</div>
<div class="input-wrapper">
<label for="name">Last Name</label>
<input type="text" placeholder="First Name..." name="lname">
</div>
<div class="input-wrapper">
<label for="name">Profile Picture</label>
<input type="file"name='upload'>
</div>
<input type="submit" class="button" name="submit" value="SUBMIT">
</form>
<?php include 'footer.php' ?>


27 changes: 27 additions & 0 deletions giorgi_durglishvili/profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php include 'header.php' ?>
<?php
session_start();
if(isset($_SESSION['fname'])){
$fname = $_SESSION['fname'];
$lname = $_SESSION['lname'];
$image = $_SESSION['file_name'];
}else{
header('location: index.php');
exit();
}

?>
<a href="includes/logout.inc.php">
<div class="button">
Log Out
</div>
</a>

<div class="profile-component">
<img src="<?php echo $image; ?>" alt="image">
<div class="full-name">
<?php echo "$fname $lname" ?>
</div>
</div>

<?php include 'footer.php' ?>
19 changes: 0 additions & 19 deletions oto_zakalshvili/form.php

This file was deleted.

9 changes: 0 additions & 9 deletions oto_zakalshvili/index.php

This file was deleted.