doushou8730 2010-12-21 08:01
浏览 54
已采纳

表格验证丢失变量

Let's say I enter a registration form with this ending URL: registration.php?accountType=a The form is parsed on the same page (registration.php). If the user doesn't pass form validation they are taken to registration.php with error messages. So you see I lost my variable accountType=a. My question:

Can I submit a form for validation and retain the accountType variable? I'm aware that this could easily be done using a cookie. I just want a further understanding.

Solution: Although all of the answers below were valid, I went with a Session variable and <form action="registration.php?<?php print 'accountType=' . $_SESSION['accountType']; ?>" etc. Thanks for the help.

  • 写回答

3条回答 默认 最新

  • duanbin3021 2010-12-21 08:06
    关注

    You should use this in your form:

    <form action="registration.php?accountType=a">
    

    You should use this in your php:

    if ($validation_success) {
        header('sucess.php')
    } else {
        // don't do anything. The page(registration.php?accountType=a) loads
    }
    

    I'm just giving you the idea.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序