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 运筹学中在线排序的时间在线排序的在线LPT算法
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧