le 18/09/2012 à 18:38
asmaa1988
Bonjour,je viens de créer un formulaire pour modifier des le pseudo, dans ma base de données j'ai trois champs: le id le login et le mot de passe, je développe sous phpMyAdmin.
voici le code de la page du formulaire:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>BLOG GI - Bienvenue</title>
<link href="style.css" rel="stylesheet" />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="conteneur">
<h1>BLOG GI</h1>
<nav>
<ul>
<li><a href="espace.php" id="propos">Retour</a></li>
</ul>
<div id="contenu">
<div id="contenu1">
<article class="gauche">
<h2>Modifier mon compte</h2>
<form action="modifpseudo.php" method="POST">
<ul>
<li>
<label for="nom">Ancien pseudo: </label>
<input type="text" id="anpseudo" name="anpseudo"/>
</li>
<li>
<label for="nom">Nouveau pseudo: </label>
<input type="text" id="npseudo" name="npseudo"/>
</li>
<li>
<input type="submit" id="valider" name="valider" value="Valider"/>
</li>
</ul>
</form>
<!-- <form action="" method="post">
<ul>
<li>
<label for="nom"> Ancien mot de passe: </label>
<input type="password" id="nom" name="nom"/>
</li>
<li>
<label for="nom">Nouveau mot de passe: </label>
<input type="password" id="nom" name="nom"/>
</li>
<li>
<input type="submit" id="valider" name="valider" value="Valider"/>
</li>
</ul>
</form>
<form action="espace.php" method="post">
<input type="submit" id="valider" name="valider" value="Retour a mon mur" />
</form> -->
</article>
<div class="droite">GESTIONCOMPTE</div>
</div>
</div>
</div>
</div>
</html>
voici le code de modification:
<?php
include('connexion.php');
if(isset($_POST['anpseudo']) and isset($_POST['npseudo'])){
if(!empty($_POST['anpseudo']) and !empty($_POST['npseudo'])){
$logo = $_POST['npseudo'];
$logi = $_GET['anpseudo'];
//mysql_query("DELETE FROM users WHERE login='".$logi."'");
//mysql_query("INSERT INTO users VALUES('','".$logo."')");
$requete = "UPDATE users SET login= '"$_POST['npseudo']"' WHERE login= '" $_POST['anpseudo']"' ";
mysql_query($requete);
echo "Pseudo modifié";}}
else
{
echo "blalalal";
include('sinscrire.php');
}
?>
MAIS ON MAFFICHE RIEN
voici le code de la page du formulaire:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>BLOG GI - Bienvenue</title>
<link href="style.css" rel="stylesheet" />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="conteneur">
<h1>BLOG GI</h1>
<nav>
<ul>
<li><a href="espace.php" id="propos">Retour</a></li>
</ul>
<div id="contenu">
<div id="contenu1">
<article class="gauche">
<h2>Modifier mon compte</h2>
<form action="modifpseudo.php" method="POST">
<ul>
<li>
<label for="nom">Ancien pseudo: </label>
<input type="text" id="anpseudo" name="anpseudo"/>
</li>
<li>
<label for="nom">Nouveau pseudo: </label>
<input type="text" id="npseudo" name="npseudo"/>
</li>
<li>
<input type="submit" id="valider" name="valider" value="Valider"/>
</li>
</ul>
</form>
<!-- <form action="" method="post">
<ul>
<li>
<label for="nom"> Ancien mot de passe: </label>
<input type="password" id="nom" name="nom"/>
</li>
<li>
<label for="nom">Nouveau mot de passe: </label>
<input type="password" id="nom" name="nom"/>
</li>
<li>
<input type="submit" id="valider" name="valider" value="Valider"/>
</li>
</ul>
</form>
<form action="espace.php" method="post">
<input type="submit" id="valider" name="valider" value="Retour a mon mur" />
</form> -->
</article>
<div class="droite">GESTIONCOMPTE</div>
</div>
</div>
</div>
</div>
</html>
voici le code de modification:
<?php
include('connexion.php');
if(isset($_POST['anpseudo']) and isset($_POST['npseudo'])){
if(!empty($_POST['anpseudo']) and !empty($_POST['npseudo'])){
$logo = $_POST['npseudo'];
$logi = $_GET['anpseudo'];
//mysql_query("DELETE FROM users WHERE login='".$logi."'");
//mysql_query("INSERT INTO users VALUES('','".$logo."')");
$requete = "UPDATE users SET login= '"$_POST['npseudo']"' WHERE login= '" $_POST['anpseudo']"' ";
mysql_query($requete);
echo "Pseudo modifié";}}
else
{
echo "blalalal";
include('sinscrire.php');
}
?>
MAIS ON MAFFICHE RIEN