php - Session variable to show a form or not -
i want show form if previous form filled , submitted. so, created session variable initialized when submit first form. :
if( $flag) { $_session['id_essai'] = $id_essai; echo $_session['id_essai']; insertion_base($index_essai,$id_essai,$nom_local_essai,$nombre_traitements,$essai_ou_suivis,$thematique); }
i can var
in file because echo works , return value.
after :
if(isset($_session['id_essai'])) { echo' <div id="tab_traitement" class="excel"></div> <form action="#" method="post"> <button type="button" class="btn btn-default" id="submit_button_traitement">submit</button> </form> '; }else echo'pour saisir un traitement, vous devez d\'abord faire la saisie d\'un essai';
this index.php :
<?php session_start();?> <!doctype html> <meta charset="utf-8"> <head> <title></title> </head> <body> <?php include('onglets.php');?> </body>
in file 'onglets.php' : i've got :
<div class="tabs" id="tabs"> <ul> <li><a href="#tabs-1">essai</a></li> <li><a href="#tabs-2">traitement</a></li> <li><a href="#tabs-3">itk pro</a></li> <li><a href="#tabs-4">itk </a></li> <li><a href="#tabs-5">parcelle élémentaire</a></li> <li><a href="#tabs-6">prélèvement</a></li> <li><a href="#tabs-7">analyse</a></li> <li><a href="#tabs-8">mesure plante principale</a></li> <li><a href="#tabs-9">mesure plante cipan</a></li> <li><a href="#tabs-10">station climatique</a></li> </ul> <div id="tabs-1"> <?php include('essai.php');?> </div> <div id="tabs-2"> <?php include('traitement.php');?> </div> <div id="tabs-3"> <?php include('itk_pro.php');?> </div> <div id="tabs-4"> <?php include('itk.php');?> </div> <div id="tabs-5"> <?php include('pe.php');?> </div> <div id="tabs-6"> <?php include('prelevement.php');?> </div> <div id="tabs-7"> <?php include('analyse.php');?> </div> <div id="tabs-8"> <?php include('mpp.php');?> </div> <div id="tabs-9"> <?php include('mpc.php');?> </div> <div id="tabs-10"> <?php include('station_climatique.php');?> </div> </div> <div id="tabid"></div>
and call ajax_insert_essai.php in essai.php. in ajax_insert_essai.php, initialize $_session['id_essai'].
and have session_start()
@ beginning without before that's not probem. please, help!
how can ?
this because use ajax. javascript client side , php server side. page form not recharged, isn't processed server, won't able see session variable unless refresh page
two solutions :
refresh page after submitting first form or use client-side method, javascript (better imo)
Comments
Post a Comment