dqef7931 2016-11-29 01:10
浏览 51
已采纳

表单添加现有的变量

I'm creating a simple form which when filled out, it will add the variable and form content to the end of https://www.example.com/clients/cart.php?a=add&pid=91

So the aim is to have a form with variable name sld and then adds this to the end of the above URL, so that it becomes https://www.example.com/clients/cart.php?a=add&pid=91&sld=CONTENT

However, the form (code below) ignores the existing variables and simply defaults to https://www.example.com/clients/cart.php (eg. cart.php?sld=CONTENT.

Is there a way to keep the existing variables and submit the form content at the end of the provided URL?

<form action="https://www.example.com/clients/cart.php?a=add&pid=91" method="get">
<input type="text" name="sld" placeholder="google">.
<input type="text" name="tld" placeholder="com">
<input type="submit" value="submit">
</form>
  • 写回答

1条回答 默认 最新

  • dsf6281 2016-11-29 01:13
    关注

    You can add two hidden fields with the value:

    <form action="https://www.example.com/clients/cart.php" method="get">
        <input type="text" name="sld" placeholder="google">.
        <input type="text" name="tld" placeholder="com">
        <input type="submit" value="submit">
        <input type="hidden" name="a" value="<?php echo $_GET['a']; ?>">
        <input type="hidden" name="pid" value="<?php echo $_GET['pid']; ?>">
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部