dongzhuo0895 2015-05-24 22:50
浏览 39
已采纳

将html表单答案存储为一个变量,以便在表单页面上使用[关闭]

I'm really new at using PHP, and I'm not really sure what kind of solution I need to be looking for, but anyway... I have created a mini-form, that only has one question. I have used a select-tag and seven option-tags. I want to save the answer from the user as a variable, that I can then use in an if-statement later, on the same page as the form was on. Is this even possible? And newbie-friendly?

  • 写回答

2条回答 默认 最新

  • ds0802 2015-05-24 23:04
    关注

    Yes, it is possible. 1. Check that you have added method in form tag (action means that you will be using same page for your if-statement) and that you have name for select element:

    <form action="?" method="get">
    <select name="question"> 
        <option value="1">one</option>
        <option value="2">two</option>
        ...
        <option value="7">seven</option>   
    </select>
    
    1. Then, after form submit the page will be reloaded and you will get selected value from $_GET["question"] variable.

    Read more about it: PHP $_GET

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

报告相同问题?

悬赏问题

  • ¥60 求会做山景bo1048b2程序的 直播声卡用
  • ¥15 51单片机与数码管实现电子琴
  • ¥15 h3.6m 人类行为预测论文复现
  • ¥50 wordpress项目注册报失败刷新后其实是成功状态,请求排查原因
  • ¥20 linxu服务器僵尸进程不释放,代码如何修改?
  • ¥15 pycharm激活不成功
  • ¥40 如果update 一个列名为参数的value
  • ¥15 基于51单片机的水位检测系统设计中LCD1602一直不显示
  • ¥15 OCS2安装出现问题,请大家给点意见
  • ¥15 ros小车启动launch文件报错