我必须将表单值保存到PHP会话中,并希望保留所有表单值,直到表单提交:
我这样试过:
$pattern = '';
if(isset($_REQUEST['submit'])) :
$s1 = $_REQUEST['step1'];
$s2 = $_REQUEST['step2'];
$s3 = $_REQUEST['step3'];
$s4 = $_REQUEST['step4'];
$pattern .= $s1.$s2.$s3;
$p_cat= $_REQUEST['p_cat'];
$_SESSION['mywine'] = $pattern;
$_SESSION['quantity'] = $_REQUEST['step4'];
if($p_cat == 'mixed')
$p_cat = 'red,white';
else $p_cat= $_REQUEST['p_cat'];
endif;
$my_wine = $_SESSION['mywine'];
$qun = $_SESSION['quantity'];
$args = array(
'post_type' => 'product',
'product_cat' => $p_cat,
'posts_per_page' => 3,
'meta_query' => array(
array(
'key' => 'product_score_pattern',
'value' => $my_wine,
'compare' => '='
)
)
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
endwhile;
endif;
此代码能够将数据保存到会话中,但是当我刷新页面时,会话值将为空。
我希望保持表格形式直到表单提交。这怎么可能?
答案 0 :(得分:0)
您必须先致电public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pelle);
Intent intent = getIntent();
eEntreprise2 = intent.getStringExtra("eEntreprise");
eAdresse2 = intent.getStringExtra("eAdresse");
eIdVerificateur2 = intent.getStringExtra("eIdVerificateur");
eNomProprio2 = intent.getStringExtra("eNomProprio");
eAdresseProprio2 = intent.getStringExtra("eAdresseProprio");
eNomEntreprise2 = intent.getStringExtra("eNomEntreprise");
eAdresseEntreprise2 = intent.getStringExtra("eAdresseEntreprise");
eJourVerif2 = intent.getStringExtra("eJourVerif");
eMoisVerif2 = intent.getStringExtra("eMoisVerif");
eAnneeVerif2 = intent.getStringExtra("eAnneeVerif");
}
才能分配或访问session_start()
变量,如下所示。
$_SESSION
好的,你正在使用wordpress,它不允许创建会话..你需要参考这个
https://wordpress.org/support/topic/sessions-not-working-tried-everything