VARIABLE ET HEADER
- Accueil
- Forum
- Programmation
- PHP
- VARIABLE ET HEADER
Julie2002 Le 11 novembre 2017 à 17:14 (Édité le 25 janvier 2019 à 17:54)
Notice: Undefined variable: mdp1 in /storage/ssd5/590/3389590/public_html/editionprofil1.php on line 96
Notice: Undefined variable: mdp2 in /storage/ssd5/590/3389590/public_html/editionprofil1.php on line 96
Notice: Undefined variable: mdp1 in /storage/ssd5/590/3389590/public_html/editionprofil1.php on line 100
Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd5/590/3389590/public_html/editionprofil1.php:96) in /storage/ssd5/590/3389590/public_html/editionprofil1.php on line 102
Voici mon code :
*
<?php
session_start();
$bdd = new PDO('mysql:host=localhost;dbname=******', '****', '***');
if(isset($_SESSION['id']))
{
$requser = $bdd->prepare("SELECT * FROM membre WHERE id = ?");
$requser->execute(array($_SESSION['id']));
$user = $requser->fetch();
$imagedefault = "default/images.jpg";
if(isset($_FILES['avatar']) AND !empty($_FILES['avatar']['name']))
{
$tailleMax = 2097152;
$extensionsValides = array('jpg', 'jpeg', 'gif', 'png');
if($_FILES['avatar']['size'] <= $tailleMax)
{
$extensionUpload = strtolower(substr(strrchr($_FILES['avatar']['name'], '.'), 1));
if(in_array($extensionUpload, $extensionsValides))
{
$chemin = "membre/avatar/".$_SESSION['id'].".".$extensionUpload;
$resultat = move_uploaded_file($_FILES['avatar']['tmp_name'], $chemin);
if($resultat)
{
$updateavatar = $bdd->prepare('UPDATE membre SET avatar = :avatar WHERE id = :id');
$updateavatar->execute(array(
'avatar' => $_SESSION['id'].".".$extensionUpload,
'id' => $_SESSION['id']
));
header('Location: profil.php?id='.$_SESSION['id']);
}
else{
$msg = "Erreur durant l'importation de votre photo de profil";
}
}
else
{
$msg = "Votre photo de profil doit être au format jpg, jpeg, gif ou png";
}
}
else
{
$msg = "Votre photo de profil ne doit pas dépasser 2Mo";
}
}
if(isset($_POST['newpseudo']) AND !empty($_POST['newpseudo']) AND $_POST['newpseudo'] != $user['pseudo']) {
$newpseudo = htmlspecialchars($_POST['newpseudo']);
$insertpseudo = $bdd->prepare("UPDATE membre SET pseudo = ? WHERE id = ?");
$insertpseudo->execute(array($newpseudo, $_SESSION['id']));
header('Location: profil.php?id='.$_SESSION['id']);
}
if(isset($_POST['newmail']) AND !empty($_POST['newmail']) AND $_POST['newmail'] != $user['mail']) {
$newmail = htmlspecialchars($_POST['newmail']);
$insertmail = $bdd->prepare("UPDATE membre SET mail = ? WHERE id = ?");
$insertmail->execute(array($newmail, $_SESSION['id']));
header('Location: profil.php?id='.$_SESSION['id']);
}
if(isset($_POST['newmdp1']) AND !empty($_POST['newmdp1']) AND isset($_POST['newmdp2']) AND !empty($_POST['newmdp2'])) {
$mdp1 = sha1($_POST['newmdp1']);
$mdp2 = sha1($_POST['newmdp2']);
}
if($mdp1 == $mdp2){
$insertmdp = $bdd->prepare("UPDATE membre SET motdepasse = ? WHERE id = ?");
$insertmdp->execute(array($mdp1, $_SESSION['id']));
header('Location: profil.php?id='.$_SESSION['id']);
}
else
{
$msg = "Vos deux mdp ne correspondent pas !";
}
?>
<html>
<head>
<title>TUTO PHP</title>
<meta charset="utf-8">
<link rel="stylesheet" href="editionprofil.php" />
</head>
<body>
<div align="center">
<h2>Edition de mon profil</h2>
<div align="left">
<form method="POST" action="" enctype="multipart/form-data">
<label>Pseudo :</label>
<input type="text" name="newpseudo" placeholder="Pseudo" value="<?php echo $user['pseudo']; ?>" /><br /><br />
<label>Mail :</label>
<input type="text" name="newmail" placeholder="Mail" value="<?php echo $user['mail']; ?>" /><br /><br />
<label>Mot de passe :</label>
<input type="password" name="newmdp1" placeholder="Mot de passe"/><br /><br />
<label>Confirmation du mot de passe :</label>
<input type="password" name="newmdp2" placeholder="Confirmation du mot de passe" /><br /><br />
<label>Avatar : </label>
<input type="file" name="avatar" /><br /> <br />
<input type="submit" value="Mettre à jour mon profil" />
</form>
</div>
</div>
</body>
</html>
<?php
}
else {
header("Location: connexion.php");
}
?>
Profil introuvable Le 12 janvier 2018 à 23:17 (Édité le 1 janvier 1970 à 01:00)