php - unable to auto increment session value -


in wordpress project want run mysql query in thank page when user redirected once time. when user refresh it, should not run. created session variable , did below way. did not work. can me.

session_start(); $_session['countval']=0;  if($_session['countval']==0){       $wpdb->insert('wp_user_points',                    array('user_id' =>$current_user->id ,                           'order_id'=>$order_id,                          'product_sku' =>$new_sku,                          'pv'=>$points,                          'added_on'=>date("y-m-d  h:i:s"),                          'payment_method'=>$order->payment_method_title,                          'payment_statues'=>'pending'                         )                   );      $_session['countval']++;  } 

because set $_session['countval']=0; in first line. use code:

session_start(); if(!isset($_session['countval']))    $_session['countval']=0;  if($_session['countval']==0){       $wpdb->insert('wp_user_points',                    array('user_id' =>$current_user->id ,                           'order_id'=>$order_id,                          'product_sku' =>$new_sku,                          'pv'=>$points,                          'added_on'=>date("y-m-d  h:i:s"),                          'payment_method'=>$order->payment_method_title,                          'payment_statues'=>'pending'                         )                   );      $_session['countval']++;    } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -