Prob Requete php

Fermé
perduquepart Messages postés 49 Date d'inscription vendredi 11 janvier 2008 Statut Membre Dernière intervention 1 novembre 2009 - 9 oct. 2008 à 19:08
incaout Messages postés 347 Date d'inscription lundi 8 septembre 2008 Statut Membre Dernière intervention 15 novembre 2012 - 9 oct. 2008 à 22:03
Bonjour, j'ai créer une requete pour pouvoir updater mes donnes ds une base de données.. mais elle est suppose ce lancer lorsque l'utilisateur clique sur enregistrer... mais rien ne fonctionne et je galere pour trouver une solution.. alors j'apprécierais un ptit coup de main :p... voici mon code.....

********************************************************************************************
if ($_POST['selItem'] =='Mon Profil')
{

/*********************************************************************
*
* Connexion au serveur de données SQL
*
**************************************************/
        $connexion = mysql_connect ('localhost','root','');
            
            if (!$connexion)
                {
                    //Si aucune connexion, traiter ceci:
                    die ('Connexion Impossible: ' .mysql_error());
                }
                
            //Structure Conditionnel onclick cmdsaveprofil
            if (isset($_POST['cmdsaveprofil']))
                
                //Si bouton cmdsaveprofil onclick, traite ceci:
                {
                    //REQUÊTE update user informations tblusers 
                                
                    $queryupdateuser = "UPDATE tblusers
                                        SET Prenom = '$_POST[txtPrenomProfil]',
                                        Nom = '$_POST[txtNomProfil]',
                                        User = '$_POST[txtUserProfil]',
                                        Password = '$_POST[txtPasswordProfil]',
                                        Email = '$_POST[txtEmailProfil]'
                                        WHERE ID = '$_SESSION[ID]'";
                                                       
                    //Sélectionnez la base de données
                    $db_selected = mysql_select_db ('dbatelier', $connexion);
                                                      
                    //Envoi de la REQUÊTE $queryupdateuser au serveur de données
                    $requeteupdateuser = mysql_query ($queryupdateuser,$connexion);
                    
                    header ("Location:".$_SERVER['PHP_SELF'] ."?selItem=Mon Profil");
                    
                }                                 
         
            else
                
                //Sinon traite ceci:
                {    
                    //REQUÊTE affichage Connect User
                    $queryconnectuser = 'Select * FROM tblusers WHERE ID ='.$_SESSION['ID'];
                    
                    //Sélectionnez la base de données
                    $db_selected = mysql_select_db ('dbatelier', $connexion);
                    
                    //Envoi de la REQUÊTE $queryconnectuser au serveur de données
                    $requeteconnectuser = mysql_query ($queryconnectuser,$connexion);
                            
                    //Assignation variable affichage REQUÊTE $queryconnectuser
                    $rowconnectuser = mysql_fetch_array ($requeteconnectuser);
                    
                    //Réaffichage Page Profil
                    //$_POST['selItem'] = "Mon Profil";
                    //header('Location:' .$_SERVER['PHP_SELF']);
                }
        
         //Fermeture de la connexion au serveur de données SQL
        mysql_close ($connexion);
    }
    
                    
                        /*********************************************************************
                        *
                        *    Construction de l'affichage tableprofil
                        *
                        **************************************************/
                        $tableprofil = "<table align=\"center\">";
                        
                                        //Affichage Champs Prenom
                                        $tableprofil .= "<tr>
                                                        <td><b>Prénom:</b></td>
                                                        <td><input type=\"text\" name=\"txtPrenomProfil\" value=\"".$rowconnectuser['Prenom']."\"></td>
                                                       <tr>";
                                                       
                                        //Affichage Champs Nom
                                        $tableprofil .= "<tr>
                                                        <td><b>Nom:</b></td>
                                                        <td><input type=\"text\" name=\"txtNomProfil\" value=\"".$rowconnectuser['Nom']."\"></td>
                                                       </tr>";
                                                       
                                        //Affichage Champs User
                                        $tableprofil .= "<tr>
                                                        <td><b>User:</b></td>
                                                        <td><input type=\"text\" name=\"txtUserProfil\" value=\"".$rowconnectuser['User']."\"></td>
                                                       </tr>";
                                        
                                        //Affichage Champs Password
                                        $tableprofil .= "<tr>
                                                        <td><b>Password:</b></td>
                                                        <td><input type=\"password\" name=\"txtPasswordProfil\" value=\"".$rowconnectuser['Password']."\"></td>
                                                       </tr>";
                                                       
                                        //Affichage Champs Confirmation Password
                                        $tableprofil .= "<tr>
                                                        <td><b>Confirmation Password:</b></td>
                                                        <td><input type=\"password\" name=\"txtConPasswordProfil\" value=\"".$rowconnectuser['Password']."\"></td>
                                                       </tr>";
                                                       
                                        //Affichage Champs Email
                                        $tableprofil .= "<tr>
                                                        <td><b>Email:</b></td>
                                                        <td><input type=\"text\" name=\"txtEmailProfil\" value=\"".$rowconnectuser['Email']."\"></td>
                                                       </tr>";
                                                       
                                        //Bouton cmdsaveprofil
                                        $tableprofil .= "<tr>
                                                         <td colspan=2 align=right><input type=\"submit\" name=\"cmdsaveprofil\" value=\"Enregistrer\"></td>
                                                         </tr>";
                                        
                        //Fermeture de tableprofil
                        $tableprofil .= "</table>";
                        
                
        //Assignation variable $profil / Affichage TOP Page profil
        $profil = "<h1><div style=\"color:#808080\">".$_SESSION['txtPrenomID'] ." " .$_SESSION['txtNomID'] ." " ."Profil" ."</div></h1><hr>
                   <b>Remplissez les champs que vous voulez modifier:</b>
                   <br><br>";
        //Ouverture de !frmtableprofil!              
        $profil .= "<form name=\"frmtableprofil\" method=\"post\" action=\"".$_SERVER["PHP_SELF"] ."\"onSubmit=\"return checkpassword()\">\n";
                           
        //Assignation variable $profil / Affichage $tableprofil
        $profil .= $tableprofil;
                        
        //Fermeture de !frmtableprofil!
        $profil .= "</form>";
                
        //Assignation variable $profil, Réaffichage de ma page
        $profil .= $rappelpage;

*****************************************************************************************
Merci pour votre aide, j'ai pas tout poster mon code.. mais je crois avoir poster ce qui est necessaire pour trouver une solution.. merci de votre aide!!

1 réponse

incaout Messages postés 347 Date d'inscription lundi 8 septembre 2008 Statut Membre Dernière intervention 15 novembre 2012 74
9 oct. 2008 à 22:03
Salut,

Je ne connais pas bien mysql et les fonctions associées en PHP, mais normalement dans le tableau $_POST, les noms des champs doivent être en '' : $_POST['nom']. D'autre part, j'aurai écris la requete comme cela :

$queryupdateuser = "UPDATE tblusers
SET Prenom = '" . $_POST['txtPrenomProfil'] . "',
Nom = '" . $_POST['txtNomProfil'] . "',
User = '" . $_POST['txtUserProfil'] . "',
Password = '" . $_POST['txtPasswordProfil'] . "',
Email = '" . $_POST['txtEmailProfil'] ."'
WHERE ID = " . $_SESSION['ID'] ;

Cdlt

IC
-1