douren7179 2019-04-27 08:54
浏览 76

如何增加会话变量以进行提交

I have form to add employess to database. I have to count how many employess were added during one session and display it somewhere on the screen.

Right now my form_validation.php looks like this:

<?php
 session_start();

 if(formValidationIsCorrect){
   $_SESSION['counter']++;
   header("location:pageWithFormDetails.php);
 }

in pageWithFormDetails.php I have to display employee information from form (name, age, etc.), and how many employess were added during this session.

My problem is, that when on pageWithFormDetails.php I do

<?php echo $_SESSION['counter']; ?> it always displays 1, even If i refill form few times. I guess everytime I complete form, my counter variable is reset, and then incremented by 1. Is there a way not to reset this variable every time I complete form, and validate it?

  • 写回答

2条回答 默认 最新

  • duanchu2607 2019-04-27 09:32
    关注

    You need to use database input and then output. When you are attempting to $_SESSION ++. There you can use ++ in db variable then -1 when you are destroying the session. That's how I did this when I needed similar type of thing.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度