简体   繁体   English

Sava搜索查询并停留在同一页面上

[英]Sava search query and stay on same page

I am having trouble with my php code. 我的php代码有问题。 I have tried everything and nothing works. 我已经尝试了一切,但没有任何效果。 I want that the form will save the search query into the database but but i canot use action="search.php" since the result is displayed on the index.php page so it need's to stay on the index page and execut the save. 我希望该表单将搜索查询保存到数据库中,但是我不能使用action="search.php"因为结果显示在index.php页面上,因此它需要保留在索引页面上并执行保存。

The form: 表格:

<form class="form-domain" role="form" action="search.php" method=post>

<!-- Search input -->
<div class="search-input">
<span class="www">www.</span>
<input type="text" class="form-control input-domain" placeholder="vasa-nova-domena" name="ime_domene">
<div class="domain-extension">
<select class="form-control" name="koncnica">
<option value=".com" selected="">.com</option>
<option value=".si">.si</option>
</select>
</div>
</div><!-- /.search-input -->

<button class="btn btn-success btn-block" id="poslji" name="preglej" type="submit"><strong>PREVERI</strong></button>

</form>

Right after this form comes the php result so i need to stay on the index.php to have the result of the search visible but the same time i want the input/search that was given saved into the database. 在这种形式出现之后,php结果立即出现,因此我需要保留在index.php上,以使搜索结果可见,但与此同时,我希望将给出的输入/搜索保存到数据库中。

I hope this wasen't to complicated. 我希望这不会太复杂。 :) :)

<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("POST","<?php include 'search.php';?>",true);
xmlhttp.send();
}
}
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM