Page 1 sur 1

ajout donne dans bdd avec $_session

Posté : 20 déc. 2012, 02:04
par neomega
bonjour ,

je souhaite insérer mes données dans ma base sql j'ai une erreur :

Notice: Undefined variable: SESSION in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\centrale\form_4.php on line 10

et autant jusqua ligne 29

pourtant juste avant de mettre mon script " ajout a bdd " j'ai fait une sorte de recapitulatif et la toute les donnee apparaisser nikel



c'est en ajoutant ceci que sa me met ces erreur :
	
include "info.php";	

	// on insère les donnée et au cas où, on écrira un petit message d'erreur si la requête ne se passe pas bien (or die)
		$sql = "insert into client_boutique values (
										'',
									'".$SESSION['nom']."',
									'".$SESSION['prenom']."',
									'".$SESSION['adresse']."',
									'".$SESSION['cp']."',
									'".$SESSION['ville']."',
									'".$SESSION['num1']."',
									'".$SESSION['num2']."',
									'".$SESSION['mail']."',
									'".$SESSION['corp']."',
									'".$SESSION['siret']."',
									'".$SESSION['tva_intra']."',
									'".$SESSION['cat']."',
									'".$SESSION['cat_bou']."',
									'".$SESSION['sous_categorie']."',
									'".$SESSION['salle']."',
									'".$SESSION['emp']."',
									'".$SESSION['titre']."',
									'".$SESSION['stitre']."',
									'".$SESSION['resume']."',
									'".$SESSION['url']."',
									0,
									0
									)";


		//  petit message d'erreur si la requête ne se passe pas bien (or die)
		mysql_query ($sql) or die ('Erreur SQL !'.$sql.'<br />'.mysql_error());

		// on ferme la connexion à la base
		mysql_close();


dans ma bdd sa me met des champ vide

et pourtant je laisse en dessous le récapitulatif des mes données de mes 3 pages de formulaire et la les donnée apparaisse nikel


voici ma page complete

<?php
//demarage de la session
session_start();
	
include "info.php";	

	// on insère les donnée et au cas où, on écrira un petit message d'erreur si la requête ne se passe pas bien (or die)
		$sql = "insert into client_boutique values (
										'',
									'".$SESSION['nom']."',
									'".$SESSION['prenom']."',
									'".$SESSION['adresse']."',
									'".$SESSION['cp']."',
									'".$SESSION['ville']."',
									'".$SESSION['num1']."',
									'".$SESSION['num2']."',
									'".$SESSION['mail']."',
									'".$SESSION['corp']."',
									'".$SESSION['siret']."',
									'".$SESSION['tva_intra']."',
									'".$SESSION['cat']."',
									'".$SESSION['cat_bou']."',
									'".$SESSION['sous_categorie']."',
									'".$SESSION['salle']."',
									'".$SESSION['emp']."',
									'".$SESSION['titre']."',
									'".$SESSION['stitre']."',
									'".$SESSION['resume']."',
									'".$SESSION['url']."',
									0,
									0
									)";


		//  petit message d'erreur si la requête ne se passe pas bien (or die)
		mysql_query ($sql) or die ('Erreur SQL !'.$sql.'<br />'.mysql_error());

		// on ferme la connexion à la base
		mysql_close();

?>	
    
    
    
    <body>
     <div id="content">  
     <center><h1>Recapitulatif</h1></center> 
   <div id="tableau">     
       <table><tr><td valign="top">
       
       
            <table align="center" class="table3">
                <thead>
                    <tr>
                        <th width="149"></th>
                        <th width="98" scope="col" abbr="Starter">donnee client</th>
                    </tr>
                </thead>
                <tfoot>
                    
                </tfoot>
                <tbody>
                    <tr>
                        <th scope="row">Nom</th>
                        <td><?php echo $_SESSION['nom'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">Prenom</th>
                        <td><?php echo $_SESSION['prenom'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">adresse</th>
                        <td><?php echo $_SESSION['adresse'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">code postal</th>
                        <td><?php echo $_SESSION['cp'] ?></td>
                       
                    </tr>
                    <tr>
                        <th scope="row">ville</th>
                        <td><?php echo $_SESSION['ville'] ?></td>
                       
                    </tr>
                    <tr>
                        <th scope="row"><p>telephone fixe</p></th>
                        <td><?php echo $_SESSION['num1'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row"><p>telephone portable</p></th>
                        <td><?php echo $_SESSION['num2'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">e-mail</th>
                        <td><?php echo $_SESSION['mail'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">categorie</th>
                        <td><?php echo $_SESSION['cat'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">societe</th>
                        <td><?php echo $_SESSION['corp'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">siret</th>
                        <td><?php echo $_SESSION['siret'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">tva intra</th>
                        <td><?php echo $_SESSION['tva_intra'] ?></td>
                        
                    </tr>
                </tbody>
            </table>
         

</td><td>&nbsp;</td> <td valign="top">        
         
           
			<table align="center"  class="table3">
                <thead>
                    <tr>
                        <th width="149"></th>
                        <th width="98" scope="col" abbr="Starter">donnee boutique</th>
                    </tr>
                </thead>
                <tfoot>
                    
                </tfoot>
                <tbody>
                    <tr>
                        <th scope="row">categorie</th>
                        <td><?php echo $_SESSION['cat_bou'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">Sous categorie</th>
                        <td><?php echo $_SESSION['sous_categorie'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">salle</th>
                        <td><?php echo $_SESSION['salle'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">emplacement</th>
                        <td><?php echo $_SESSION['emp'] ?></td>
                       
                    </tr>
                    <tr>
                        <th scope="row">titre</th>
                        <td><?php echo $_SESSION['titre'] ?></td>
                       
                    </tr>
                    <tr>
                        <th scope="row"><p>sous titre</p></th>
                        <td><?php echo $_SESSION['stitre'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row"><p>resume</p></th>
                        <td><?php echo $_SESSION['resume'] ?></td>
                        
                    </tr>
                    <tr>
                        <th scope="row">url</th>
                        <td><?php echo $_SESSION['url'] ?></td>
                        
                    </tr>
                   
                    
</tbody>
            </table>
            <!---- cadre photo ----->
			<table width="440" height="116" >
            <tr>
              <td height="27" align="center">
            Image boutique</td>
              <td align="center">
            Image Pop Up</td></tr>
            <tr><td height="81" align="center">
            ici
            </td><td align="center">
            ici
            </td></tr>
            </table>
            <!------------------------>           
            </td></tr></table>
      
        </div>
</div>

ps: je debute en php soyer indulgent pour mon arboressence "tres mauvaise"


merci beaucoup

Re: ajout donne dans bdd avec $_session

Posté : 20 déc. 2012, 06:13
par Patriboom
Bonjour,

je soupçonne qu'il te manque simplement la commande session_start(); http://ca2.php.net/manual/fr/function.session-start.php

Re: ajout donne dans bdd avec $_session

Posté : 20 déc. 2012, 09:18
par moogli
Salut,

Non le problème est du au fait que la variable c'est $_SESSION il manque le _



@+

Re: ajout donne dans bdd avec $_session

Posté : 20 déc. 2012, 11:32
par sirakawa
Salut,
Non le problème est du au fait que la variable c'est $_SESSION il manque le _
@+
oui et de plus:
$sql = "insert into client_boutique values (
                                                                                '',
                                                                        '".$SESSION['nom']."',
                                                                        '".$SESSION['prenom']."',
me semblerait plus facile à maitriser ainsi:
$nom = $_SESSION['nom']; 
test sur la validité du nom; real_escape et compagnie...
$prenom = $_SESSION['prenom']; 

]$sql = "insert into client_boutique values ( '$nom', '$prenom' ..

Re: ajout donne dans bdd avec $_session

Posté : 20 déc. 2012, 12:13
par neomega
merci beaucoup de votre aide c'etait bien le _ entre $ et session qui manquait


encore merci de votre efficacité

Re: [RESOLU] ajout donne dans bdd avec $_session

Posté : 20 déc. 2012, 13:18
par moogli
de rien


@+