Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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 这个逻辑有什么问题吗_Php_Html - Fatal编程技术网

Php 这个逻辑有什么问题吗

Php 这个逻辑有什么问题吗,php,html,Php,Html,我是初学者。我正在写一页。我有以下代码。但是回声没有给出任何回应。帐号输入的名称是html表单上的accountNumber i、 e 输入附件编号 去 以及go.php页面 <?php error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); if (session_status() == PHP_SESSION_

我是初学者。我正在写一页。我有以下代码。但是回声没有给出任何回应。帐号输入的名称是html表单上的accountNumber

i、 e


输入附件编号
去
以及go.php页面

<?php

        error_reporting(E_ALL | 
       E_WARNING | E_NOTICE);

       ini_set('display_errors', TRUE);

         if (session_status() == PHP_SESSION_NONE) {
      session_start();
   
         }
  
       
     
      if(!isset($_SESSION['login']))
    {
     echo (" 
       <script>location.href='../clogin/'</script>");
        die();
        }

        if (isset($_POST['submit'])) 
      {
          
  
         
     include_once('db.php');
       //get post details from user
                 
        $accountNumber = $_POST['accountNumber'];
              
          $sql = "select * from customer
           where account_number = '$accountNumber' ";           
     
               $result = mysqli_query($connection,$sql);
               
   

        if(!$result) 
        {
        die('ERROR:' . mysqli_error($connection));
    }
    
          if ($result->num_rows>0)

        {
    

        while($row = mysqli_fetch_assoc($result))
        {  
    
  
  
  
          if ($accountNumber !== $row['account_number')           
          { 
      echo"invalid";
    
         }
 
 
 
 
         else
           {
                        
       echo"valid";                           
           

              
         }//end of while        
           
        }// end of result count



              }// end submit       
              
?>

您的按钮应该由
名称
组成,因为
发布
获取
方法基于此工作

应该是

<form action="go.php" method="post">
    <label>Enter Acc. No</label>
    <input type="number" name="accountNumber" required>
    <button type="submit" name="submit">GO</button>

输入附件编号
去

注意:请使用准备好的语句来防止SQL注入

警告:您的代码容易受到SQL注入攻击。您应该使用参数化查询和准备好的语句来帮助防止攻击者使用恶意输入值破坏您的数据库。给出了风险的解释,以及如何使用PHP/mysqli安全地编写查询的一些示例。切勿将未初始化的数据直接插入SQL。按照现在编写代码的方式,有人很容易窃取、错误地更改甚至删除您的数据。还包含使用mysqli编写安全SQL的好例子。参数化查询还将大大降低由于未转义的输入值而导致意外语法错误的风险。将
name=“submit”
添加到按钮表单,当您可以使用php(如
header('location:yourpage.php')时,为什么要使用脚本位置?请学习如何使用prepare stmt来防止sql注入。在
$row['account\u number'
上,您忘记了
]
非常感谢。我会改正的
<form action="go.php" method="post">
    <label>Enter Acc. No</label>
    <input type="number" name="accountNumber" required>
    <button type="submit" name="submit">GO</button>