-
Notifications
You must be signed in to change notification settings - Fork 0
/
picture.php
134 lines (118 loc) · 3.42 KB
/
picture.php
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Change your picture</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style type="text/css">
.conteneur
{
margin-top: 40px;
height: 500px;
}
#photo
{
position: relative;
left: -1px;
top: -9px;
}
*
{
text-align: center;
}
.form
{
margin-top: 40px;
font-size: 18px;
}
.input
{
border-radius: 15px;
width: 400px;
}
#exampleInputEmail1
{
width: 300px;
margin-left: 30px;
}
#exampleInputPassword1
{
width: 300px;
margin-left: 30px;
}
.erreur
{
position: absolute;
top: 100px;
left: 550px;
color: red;
font-size: 18px;
}
</style>
</head>
<body>
<?php include('Search.php') ?>
<div class="conteneur">
<form action="picture.php" method="POST" enctype="multipart/form-data" >
<h3>Change your Profil Picture </h4>
<div class="form-group">
</div>
<div class="PhotoDeProfil">
<img src="img/image.jpg" alt="PhotoUser" id="photo">
<input type="file" name="pdp" id="file" accept="image/*" required="required"> <!--pdp = photo de profil -->
<label for="file" id="UploadBtn">Upload photo</label>
</div>
<input type="submit" value="Submit" name="button" id="NextForPhoto">
</form>
<?php
if(isset($_POST['button'])){
include('connexion.php');
$mail=$_SESSION['email'];
$req="SELECT mot_de_passe FROM user WHERE email='$mail' ";
$res=mysqli_query($link,$req)or die ("echec select");
//ON VOIS SI IL A CHOISI UN FICHIER ET QUE ON A PAS D ERREUR
if(isset($_FILES['pdp']) and $_FILES['pdp']['error']==0)
{
$dossier= 'img/';
$temp_name=$_FILES['pdp']['tmp_name'];
//VOIR SI LE FICHIR EST UPLODER
if(!is_uploaded_file($temp_name))
{
$_SESSION['erre_pho']=1;
echo " Upload failed";
}
//VOIR SI LE FICHIR UPLODER A UNE TAILLE NORMALE 1MO
if ($_FILES['pdp']['size'] >= 3000000){
$_SESSION['erre_pho']=1;
echo "Your picture is over size";
exit;
}
//VERIFIER SI L EXTENTION EST PERMITS OU PAS
$infosfichier = pathinfo($_FILES['pdp']['name']);
$extension_upload = $infosfichier['extension'];
$extension_upload = strtolower($extension_upload);
$extensions_autorisees = array('png','jpeg','jpg');
if (!in_array($extension_upload, $extensions_autorisees))
{
$_SESSION['erre_pho']=1;
echo "Your picture should have onother extension ";
exit();
}
$nom_photo= $_SESSION['Lname'].strtotime($_SESSION["date"]).".".$extension_upload;
// ON VOIS SI LE CHANGEMENT D EMPLACEMENT A BIEN PASSER
if(!move_uploaded_file($temp_name,$dossier.$nom_photo)){
$_SESSION['erre_pho']=1;
header('Location: SigninImg.php ');
}
$ph_name=$nom_photo;
}
//SI IL N A PAS CHOISI UN FICHIER
$_SESSION['ph_name']=$ph_name;
$red="UPDATE user SET photo='$ph_name' WHERE email=$mail";
$result=mysqli_query($link,$red)or die ("echec update");
}
?>
</body>
</html>