Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php POST在我的电脑上不起作用_Php_Html_Forms_Post - Fatal编程技术网

Php POST在我的电脑上不起作用

Php POST在我的电脑上不起作用,php,html,forms,post,Php,Html,Forms,Post,我试图用Post从我的表单中读取一些内容,但即使是一个简单的例子也不起作用。我自己的代码是: <form id="eingabe" method="post" action="../php/suche.php"> <input id="suche" name="suche" type="text" size="50px" placeholder="Suche"> <input type="submit" value="Submit"> <

我试图用Post从我的表单中读取一些内容,但即使是一个简单的例子也不起作用。我自己的代码是:

<form id="eingabe" method="post" action="../php/suche.php">
    <input id="suche" name="suche" type="text" size="50px" placeholder="Suche">
    <input type="submit" value="Submit">
</form>
var\u dump($\u POST)
始终是
array(0){}
,但在
var\u dump($GLOBALS)
中,我可以找到我发送的单词:

array(6) { ["HTTP_RAW_POST_DATA"]=> string(10) "suche=test" ["_GET"]=> array(0) { } ["_POST"]=> array(0) { }...
问题是:

我正在使用php7.1,但已经尝试了较旧的版本。 如果我改成让它工作,但我真的需要使用POST。 我还检查了我的php.ini,但POST被激活,ussage有128MB。 有人知道为什么Post不适合我吗


PS:我的一个朋友正在使用完全相同的代码,它对他非常有效,因此它不是代码

您可以这样编写代码-

 $rows = array();
 if($_SERVER["REQUEST_METHOD"] == "POST"){
   $suche = $_POST['suche'];
   $sql= "SELECT * FROM Buch WHERE  titel LIKE '%" . $suche . "%' OR autor LIKE '%" . $suche  ."%' OR isbn LIKE '%" . $suche  ."%' OR genre LIKE '%" . $suche  ."%'";
   $result=$conn->query($sql);
   if ($result->num_rows > 0) {
      while ($row=$result->fetch_assoc()) {
          $titel = $row['titel'];
          $autor = $row['autor'];
          $isbn = $row['isbn'];
          $genre = $row['genre'];
          $preis = $row['preis'];
          $bild = $row['image'];
          $beschreibung = $row['beschreibung'];
          $rows[] = $row;
      }
      echo "<pre>";
      print_r($rows);
  }
 }else{
   echo "POST method not working";
 }
$rows=array();
如果($\服务器[“请求\方法”]=“发布”){
$suche=$_POST['suche'];
$sql=“SELECT*FROM Buch,其中titel类似“%”,$suche.“%”或autor类似“%”,$suche.“%”或isbn类似“%”,$suche.“%”或类型类似“%”,$suche.“”;
$result=$conn->query($sql);
如果($result->num_rows>0){
而($row=$result->fetch_assoc()){
$titel=$row['titel'];
$autor=$row['autor'];
$isbn=$row['isbn'];
$GREEP=$row['GREEP'];
$preis=$row['preis'];
$bild=$row['image'];
$beschreibung=$row['beschreibung'];
$rows[]=$row;
}
回声“;
打印(行);
}
}否则{
回显“POST方法不工作”;
}
在这里,如果您的POST方法不起作用,那么您将收到一条消息“POST方法不起作用”,如果您的POST方法起作用,那么您将使用print\u r()函数获取数据


注意-此代码仅用于测试目的,请根据您的需要进行修改。

“注意:未定义的偏移量:0 in…”应为
if($\u服务器[“请求方法”]=“POST”){
-右方括号位置错误。很抱歉输入错误,没有警告,但仍然没有更改,$\u POST中仍然没有内容,如果您没有使用POST方法,则表示POST方法正在工作。可能还有其他错误。请尝试打印
$suche
,然后查看数据是否来自t如果有数据,则打印查询字符串(
$sql
)然后将查询复制并尝试直接执行到phpmyadmin中,然后查看查询是否工作。@Mempori我认为这可能是您的浏览器,因为这可能会导致问题。正如您所说,您的代码在friends PC上工作正常。请尝试其他浏览器,因为您的浏览器可能会受到影响。您和您的朋友是否在同一台服务器上运行代码?如果不是,您和您的朋友是否在同一台服务器上运行代码friend是否有相同的服务器配置并重新编写规则?我们正在lokally工作,只有数据库在服务器上?如果这回答了您的问题,PHP是一种服务器端语言,无论运行什么,它都是您的服务器。因此,我们都使用PHP版本7.0.20RC1,甚至使用相同的PHP.ini
 $rows = array();
 if($_SERVER["REQUEST_METHOD"] == "POST"){
   $suche = $_POST['suche'];
   $sql= "SELECT * FROM Buch WHERE  titel LIKE '%" . $suche . "%' OR autor LIKE '%" . $suche  ."%' OR isbn LIKE '%" . $suche  ."%' OR genre LIKE '%" . $suche  ."%'";
   $result=$conn->query($sql);
   if ($result->num_rows > 0) {
      while ($row=$result->fetch_assoc()) {
          $titel = $row['titel'];
          $autor = $row['autor'];
          $isbn = $row['isbn'];
          $genre = $row['genre'];
          $preis = $row['preis'];
          $bild = $row['image'];
          $beschreibung = $row['beschreibung'];
          $rows[] = $row;
      }
      echo "<pre>";
      print_r($rows);
  }
 }else{
   echo "POST method not working";
 }