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.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器