-
Notifications
You must be signed in to change notification settings - Fork 0
/
modifierprofil.php
151 lines (116 loc) · 5.56 KB
/
modifierprofil.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<html>
<head>
<meta charset="utf-8" />
<title> Modifier Profil </title>
<link rel ="stylesheet" href="style.css"/>
<script src="script.js"></script>
<?php
include("barreoutils.php");
?>
</head>
<?php
if (isset($_FILES['modifprofil'])) {
if ($_FILES['modifprofil']['error'] > 0) $erreur = "Erreur lors du transfert";
$maxsize=103000;
if ($_FILES['modifprofil']['size'] > $maxsize) $erreur = "Le fichier est trop gros";
$name = $_FILES['modifprofil']['name'];
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png' );
$extension_upload = strtolower( substr( strrchr($_FILES['modifprofil']['name'], '.') ,1) );
if ( in_array($extension_upload,$extensions_valides) ) {
echo "Extension correcte";
}
else echo"<script>alert('Ce fichier n'est pas une image');</script>";
$nom = "profil/{$name}";
$resultat = move_uploaded_file($_FILES['modifprofil']['tmp_name'],$nom);
if ($resultat) {
$bdd = new PDO("mysql:host=localhost;dbname=librarie", "root", "");
$mailSes = $_SESSION['email'];
$requeteMod = $bdd->prepare("UPDATE profil SET profil_picture = ? WHERE email=\"$mailSes\" ");
$requeteMod->execute(array($nom));
}
}
?>
<?php
$bdd = new PDO("mysql:host=localhost;dbname=librarie", "root", "");
$mailSes = $_SESSION['email'];
$requetePro = $bdd->query("SELECT * FROM profil WHERE email=\"$mailSes\"");
$resultPro = $requetePro->fetch();
$pass = $_SESSION['pass'];
if(isset($_POST['modprenom']) AND !empty($_POST['modprenom']))
{
$requeteMod = $bdd->prepare("UPDATE profil SET prenom = ? WHERE email=\"$mailSes\" ");
$requeteMod->execute(array($_POST['modprenom']));
}
if(isset($_POST['modnom']) AND !empty($_POST['modnom']))
{
$requeteMod = $bdd->prepare("UPDATE profil SET nom = ? WHERE email=\"$mailSes\" ");
$requeteMod->execute(array($_POST['modnom']));
}
if(isset($_POST['modnewpass']) AND isset($_POST['modconfinewpass']) AND isset($_POST['pass']) AND !empty($_POST['pass']) AND !empty($_POST['modnewpass']) AND !empty($_POST['modconfinewpass']))
{
if($pass==$_POST['pass'])
{
if($_POST['modconfinewpass']==$_POST['modnewpass'])
{
$requeteMod = $bdd->prepare("UPDATE profil SET pass = ? WHERE email=\"$mailSes\" ");
$requeteMod->execute(array($_POST['modnewpass']));
}
}
}
?>
<body>
<div class="login" id="modpro">
<div id="inscriptionH2"> Modifier ses Informations</div>
<br> <br>
<form name="modifierp" onSubmit="return formValidation();" action="modifierprofil.php" method="post">
<div class="modifierBloc">
<div class="infoProfil">
<p>
<?php echo $resultPro['prenom']; ?>
</p>
</div>
<p>
<label for="prenom"></label>
<input type="text" name="modprenom" placeholder="Prénom à modifier" class="form inp4 modif1" />
<input type="submit" value="Modifier Prénom" class="inp4 bouton modif2" ></code>
</p>
</div>
<div class="modifierBloc">
<div class="infoProfil">
<p>
<?php echo $resultPro['nom']; ?>
</p>
</div>
<p>
<label for="nom"></label>
<input type="text" name="modnom" placeholder="Nom à modifier" class="form inp4 modif1" />
<input type="submit" value="Modifier Nom" class="inp4 bouton modif2" ></code>
</p>
</div>
<div class="modifierBloc">
<div class="infoProfil">
<p>
Password
</p>
</div>
<p> <label for="pass"></label>
<input type="password" name="pass" placeholder="ancien mot de passe" class="inp4 form modif1" minlength="6"/>
</p>
<p> <label for="newpass"></label>
<input type="password" name="modnewpass" placeholder="nouveau mot de passe" class="inp4 form modif1" minlength="6"/>
</p>
<p> <label for="confinewpass"></label>
<input type="password" name="modconfinewpass" placeholder="confirmation nouveau mot de passe" class="inp4 form modif1" minlength="6"/>
<input type="submit" value="Modifier Mot de Passe" class="inp4 bouton modif2 modif3" ></code>
</p>
</div>
<p>
</form>
<form method="post" action="modifierprofil.php" enctype="multipart/form-data">
<input type="file" id="modifprofil" class="btn" name="modifprofil">
<input type="submit" value="Modifier photo de profil" id="modifierprof" class="bouton">
</p>
</form>
</div></div>
</body>
</html>