dongzhiji0814 2016-01-14 18:13
浏览 27
已采纳

PHP表单不发送GET [重复]

So I'm working on a searchfunction for my webwshop and I've gotten pretty far. I've set the GET function up with the SELECT code on the search.php file. So I "pretty confidently" thought lets just quickly do the form and I'm done....

Well not so easy as it turns out. I've got this code now and I can't seem to send the data with the get. When you search something now all you get is http://buitenlandseproducten.nl/search.php?id= but nothing stored in the id.

  <div class="form-group">
    <span class="col-md-1 col-md-offset-1 text-center"><i class="fa fa-envelope-o bigicon"></i></span>
    <div class="col-md-8">
      <input id="form" name="form" type="text" placeholder="Search" class="form-control" >
    </div>
    <div class="col-md-12 text-center">
      <?php
        echo '<p>'. '<a href="search.php?id='.$_POST['form'].'">' . '<button type="submit" class="btn btn-secondary">' . 'Search' . '</button>' . '</a>' . '<br />';
      ?>
    </div>
  </div>

If someone could help me out here you'll be my hero forever! Help would be greatly appreciated!!

</div>
  • 写回答

4条回答 默认 最新

  • duanshan3065 2016-01-14 18:28
    关注
    <form method="GET" action="search.php">
    <input id="form" name="id" type="text" placeholder="Search" class="form-control" />
    <input type='Submit' Value="Search!"/>
    </form>
    

    This should give you what i want.

    <div class="form-group">
        <span class="col-md-1 col-md-offset-1 text-center"><i class="fa fa-envelope-o bigicon"></i></span>
        <div class="col-md-8">
             <form method="GET" action="search.php">
    <input id="form" name="id" type="text" placeholder="Search" class="form-control" />
    <input type='Submit' Value="Search!"/>
    </form>
        </div>
        <div class="col-md-12 text-center">
          <?php
           // I don't know why you have this echo below here, its not necessary for what you're trying 
    // echo '<p>'. '<a href="search.php?id='.$_POST['form'].'">' . '<button type="submit" class="btn btn-secondary">' . 'Search' . '</button>' . '</a>' . '<br />';
          ?>
        </div>
      </div>
    

    The href element to link to the search.php and create a get field and assign a value to it from A POST field is kind of stretching it, and not a real smart way to go about doing it. Good luck to you, you'll need it :)

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

报告相同问题?

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳