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

将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条)

报告相同问题?