Php 数据库记录不更新?

Php 数据库记录不更新?,php,mysql,Php,Mysql,我有一个正确的数据库,我在一个页面(Login.php)上显示了一个表,并且在每个数据库记录上都有必要的编辑链接-> echo "<td><a href='../DAL/edit_consultant.php?ID=$arrRows[Consultant_Id]'>Edit</a>"; 编辑_consultant.php: <?php include "../PHP/head.php"; ini_set("dis

我有一个正确的数据库,我在一个页面(Login.php)上显示了一个表,并且在每个数据库记录上都有必要的
编辑
链接->

echo "<td><a href='../DAL/edit_consultant.php?ID=$arrRows[Consultant_Id]'>Edit</a>";
编辑_consultant.php:

    <?php
        include "../PHP/head.php";
        ini_set("display_errors", 1);
        ini_set("display_startup_errors", 1);
        error_reporting(-1);

        require_once("db_functions.php");
      require_once("../BLL/validate_form.php");

    // $strConsultant_Id = $strFirst_Name = $strLast_Name = $strHome_Phone = "";
    // $strMobile = $strEmail = $strDate_Commenced = $strDOB = $strStreet_Address = "";
    // $strSuburb = $strPost_Code = "";

    $booDate_Commenced = $booConsultant_Id = $booLast_Name = $booHome_Phone = $booMobile = 0;
    $booEmail = $booDOB = $booStreet_Address = $booFirst_Name = $booSuburb = $booPost_code = 0;


    $booOk = 1;

        echo "<br />";
        echo "<br /><br /><br />";
        if(isset($_POST["submit"])){
          updateConsultant();
        }
        else{
            if(isset($_GET["ID"])) $strConsultant_Id = $_GET["ID"];
            readQuerySingle("D_Consultant", "Consultant_Id", $strConsultant_Id, "NonNumeric");

            //If there is a record continue
            if($numRecords == 0){
                echo "<span class='error'>No Matching Branch Found!</span><br /><br />";

            } 
            else{
                $arrRows = NULL;

                //Get first and only result from database

                $arrRows = $stmt->fetch(PDO::FETCH_ASSOC);

                $strConsultant_Id = $arrRows['Consultant_Id'];
                $strFirst_Name = $arrRows['First_Name'];
                $strLast_Name = $arrRows['Last_Name'];
                $strHome_Phone = $arrRows['Home_Phone'];
                $strMobile = $arrRows['Mobile'];
                $strEmail = $arrRows['Email'];
                $strDate_Commenced = $arrRows['Date_Commenced'];
                $strDOB = $arrRows['DOB'];
                $strStreet_Address = $arrRows['Street_Address'];
            $strSuburb = $arrRows['Suburb'];
            $strPost_Code = $arrRows['Post_Code'];


            }
        }

           echo "<form action='edit_consultant.php' method='post'><table id='mavis'>";
           echo "<tr><th>Consultant Id</th><td><input type='text' name='strConsultant_Id' size='20' value='".$strConsultant_Id."' /></td>";
           if($booConsultant_Id) echo "<td>Please enter a Consultant Id</td>";

           echo "<tr><th>First Name</th><td><input type='text' name='strFirst_Name' size='20' value='".$strFirst_Name."' /></td>";
           if($booFirst_Name) echo "<td>Please Enter your First Name</td>";

           echo "<tr><th>Last Name</th><td><input type='text' name='strLast_Name' size='20' value='".$strLast_Name."' /></td>";
           if($booLast_Name) echo "<td>Please enter a Last Name</td>";

           echo "<tr><th>Home Phone</th><td><input type='text' name='strHome_Phone' size='20' value='".$strHome_Phone."' /></td>";
           if($booHome_Phone) echo "<td>Please enter a Home Phone</td>";

           echo "<tr><th>Mobile Number</th><td><input type='text' name='strMobile' size='20' value='".$strMobile."' /></td>";
           if($booMobile) echo "<td>Please enter a Mobile Number</td>";

           echo "<tr><th>Email</th><td><input type='text' name='strEmail' size='20' value='".$strEmail."' /></td>";
           if($booEmail) echo "<td>Please enter an Email!</td>";

           echo "<tr><th>Date Commenced</th><td><input type='text' name='strDate_Commenced' size='20' value='".$strDate_Commenced."' /></td>";
           if($booDate_Commenced) echo "<td>Please enter a Date Commenced!</td>";

           echo "<tr><th>DOB</th><td><input type='text' name='strDOB' size='20' value='".$strDOB."' /></td>";
           if($booDOB) echo "<td>Please enter a DOB Number!</td>";

           echo "<tr><th>Street_Address</th><td><input type='text' name='strStreet_Address' size='20' value='".$strStreet_Address."' /></td>";
           if($booStreet_Address) echo "<td>Please enter a  Street_Address!</td>";

           echo "<tr><th>Street_Address</th><td><input type='text' name='strSuburb' size='20' value='".$strSuburb."' /></td>";
           if($booSuburb) echo "<td>Please enter a Suburb!</td>";

           echo "<tr><th>Post Code</th><td><input type='text' name='strPost_Code' size='20' value='".$strPost_Code."' /></td>";
           if($booPost_code) echo "<td>Please enter a Post Code !</td>";


           echo "<tr><td></td><td><input type='submit' name='submit' value='Submit New Details' /></td></tr></table></form>";


      include "../PHP/footer.php";  
    ?>    




这些都是解决问题所需的代码?这里没有,但它在一个驱动器文件夹中--如果你想看得更清楚:)呃。。。即使不看代码的其余部分,也会有很多问题。。。1) 为什么要将字符串变量设置为整数0作为“消隐”它们的一种方式?2)
如果($booConsultant_Id)回显“请输入顾问Id”-如果boou Id为true,则是否回显错误?你的逻辑是错误的(或者我们误解了什么?)3)你的函数是什么以及它[有用]的参数在哪里?4) 为什么您的
login.php
有不止一个与登录相关的内容看来你还没有考虑过网站的结构……代码容易受到sql注入的攻击
    <?php
        include "../PHP/head.php";
        ini_set("display_errors", 1);
        ini_set("display_startup_errors", 1);
        error_reporting(-1);

        require_once("db_functions.php");
      require_once("../BLL/validate_form.php");

    // $strConsultant_Id = $strFirst_Name = $strLast_Name = $strHome_Phone = "";
    // $strMobile = $strEmail = $strDate_Commenced = $strDOB = $strStreet_Address = "";
    // $strSuburb = $strPost_Code = "";

    $booDate_Commenced = $booConsultant_Id = $booLast_Name = $booHome_Phone = $booMobile = 0;
    $booEmail = $booDOB = $booStreet_Address = $booFirst_Name = $booSuburb = $booPost_code = 0;


    $booOk = 1;

        echo "<br />";
        echo "<br /><br /><br />";
        if(isset($_POST["submit"])){
          updateConsultant();
        }
        else{
            if(isset($_GET["ID"])) $strConsultant_Id = $_GET["ID"];
            readQuerySingle("D_Consultant", "Consultant_Id", $strConsultant_Id, "NonNumeric");

            //If there is a record continue
            if($numRecords == 0){
                echo "<span class='error'>No Matching Branch Found!</span><br /><br />";

            } 
            else{
                $arrRows = NULL;

                //Get first and only result from database

                $arrRows = $stmt->fetch(PDO::FETCH_ASSOC);

                $strConsultant_Id = $arrRows['Consultant_Id'];
                $strFirst_Name = $arrRows['First_Name'];
                $strLast_Name = $arrRows['Last_Name'];
                $strHome_Phone = $arrRows['Home_Phone'];
                $strMobile = $arrRows['Mobile'];
                $strEmail = $arrRows['Email'];
                $strDate_Commenced = $arrRows['Date_Commenced'];
                $strDOB = $arrRows['DOB'];
                $strStreet_Address = $arrRows['Street_Address'];
            $strSuburb = $arrRows['Suburb'];
            $strPost_Code = $arrRows['Post_Code'];


            }
        }

           echo "<form action='edit_consultant.php' method='post'><table id='mavis'>";
           echo "<tr><th>Consultant Id</th><td><input type='text' name='strConsultant_Id' size='20' value='".$strConsultant_Id."' /></td>";
           if($booConsultant_Id) echo "<td>Please enter a Consultant Id</td>";

           echo "<tr><th>First Name</th><td><input type='text' name='strFirst_Name' size='20' value='".$strFirst_Name."' /></td>";
           if($booFirst_Name) echo "<td>Please Enter your First Name</td>";

           echo "<tr><th>Last Name</th><td><input type='text' name='strLast_Name' size='20' value='".$strLast_Name."' /></td>";
           if($booLast_Name) echo "<td>Please enter a Last Name</td>";

           echo "<tr><th>Home Phone</th><td><input type='text' name='strHome_Phone' size='20' value='".$strHome_Phone."' /></td>";
           if($booHome_Phone) echo "<td>Please enter a Home Phone</td>";

           echo "<tr><th>Mobile Number</th><td><input type='text' name='strMobile' size='20' value='".$strMobile."' /></td>";
           if($booMobile) echo "<td>Please enter a Mobile Number</td>";

           echo "<tr><th>Email</th><td><input type='text' name='strEmail' size='20' value='".$strEmail."' /></td>";
           if($booEmail) echo "<td>Please enter an Email!</td>";

           echo "<tr><th>Date Commenced</th><td><input type='text' name='strDate_Commenced' size='20' value='".$strDate_Commenced."' /></td>";
           if($booDate_Commenced) echo "<td>Please enter a Date Commenced!</td>";

           echo "<tr><th>DOB</th><td><input type='text' name='strDOB' size='20' value='".$strDOB."' /></td>";
           if($booDOB) echo "<td>Please enter a DOB Number!</td>";

           echo "<tr><th>Street_Address</th><td><input type='text' name='strStreet_Address' size='20' value='".$strStreet_Address."' /></td>";
           if($booStreet_Address) echo "<td>Please enter a  Street_Address!</td>";

           echo "<tr><th>Street_Address</th><td><input type='text' name='strSuburb' size='20' value='".$strSuburb."' /></td>";
           if($booSuburb) echo "<td>Please enter a Suburb!</td>";

           echo "<tr><th>Post Code</th><td><input type='text' name='strPost_Code' size='20' value='".$strPost_Code."' /></td>";
           if($booPost_code) echo "<td>Please enter a Post Code !</td>";


           echo "<tr><td></td><td><input type='submit' name='submit' value='Submit New Details' /></td></tr></table></form>";


      include "../PHP/footer.php";  
    ?>    
    <?php include "head.php"; ?>

    <body>
    <div id="particles-js"> 
        <div class='open-text'>
            <div class='open-text-wrap login-wrap'>

            <form method='post'>
                <input type='text' placeholder="Login Code" name='strCode' />
                <input type='submit' name='submit' value='Login' />
            </form>
            <?php 
                $display = false;
                function checkCode()
                {

                }
                    if(isset($_POST["submit"])){
                        if($_POST["strCode"] === "admin"){
                            $display = true;

                        }
                        else{
                            echo "<div class='error-login'>Authentication Failed</div>";
                        }
                    }
                ?>

            </div>
        </div> 
    </div>


    <main>
    <div class='container section-one-position cont-colour'>
        <hr />
        <div class='section-one'>
        <h1>Consultant List</h1>
        </div>
        <hr />
    </div>

    <br />
    <div class='full-container'>
    <!-- DISPLAY THE TABLE FROM DATABASE -->
     <?php
        ini_set("display_errors", 1);
        ini_set("display_startup_errors", 1);
        error_reporting(-1);
        require_once("../DAL/db_functions.php");


    if($display == true)
    {
        //Run query on branch table
        readQuery("D_Consultant");


    //If there are any details in branch table continue

        if($numRecords === 0){
            echo "<p>No Branches Found!</p>";
        }   
        else{
            $arrRows = NULL;

            //Create table and headings
            echo "<table id='dalton' border='0'>";
            echo "<tr>";
            // echo "<th>Prospect_No</th>";
            echo "<th>Consultant ID</th>";
            echo "<th>Surname</th>";
            echo "<th>First Name</th>";
            echo "<th>Home Phone</th>";
            echo "<th>Mobile</th>";
            // echo "<th>Phone</th>";
            echo "<th>Email</th>";
            echo "<th>Date Commenced</th>";
            echo "<th>DOB</th>";
            echo "<th>Street Address</th>";
            echo "<th>Suburb</th>";
            echo "<th>Post code</th>";
            echo "<th></th>";


            //echo "<th>Email</th>";

            echo "</tr>";

            while($arrRows = $stmt->fetch(PDO::FETCH_ASSOC)){
                echo "<tr>";
                // echo "<td>".$arrRows['Consultant_Id']."</td>";
                echo "<td>".$arrRows['Consultant_Id']."</td>";
                echo "<td>".$arrRows['Last_Name']."</td>";
                echo "<td>".$arrRows['First_Name']."</td>";
                echo "<td>".$arrRows['Home_Phone']."</td>";
                echo "<td>".$arrRows['Mobile']."</td>";
                // echo "<td>".$arrRows['Home_Phone']."</td>";
                echo "<td>".$arrRows['Email']."</td>";
                echo "<td>".$arrRows['Date_Commenced']."</td>";
                echo "<td>".$arrRows['DOB']."</td>";
                echo "<td>".$arrRows['Street_Address']."</td>";
                echo "<td>".$arrRows['Suburb']."</td>";
                echo "<td>".$arrRows['Post_Code']."</td>";



                echo "<td><a href='../DAL/edit_consultant.php?ID=$arrRows[Consultant_Id]'>Edit</a>";
                echo "<br /><a href='../DAL/delete_confirm.php?TYPE=Consultant&amp;ID=$arrRows[Consultant_Id]'>Delete</a></td></tr>";

            }
            echo "</table>";

        }
    }
    else{
       echo "<p>Please enter your login code to view our list of consultants</p>"; 
    }

    ?>
    </div>
    <br />
    <div class='container section-one-position cont-colour'>
            <?php echo "<form action='../DAL/add_branch.php' method='post'>";
            echo "<input type='submit' value='Add a consultant' />";
            echo "</form>";

            echo "<p></P><P>$numRecords Records Returned</P>";?>
    </div>

    <!-- CONSULTANT LIST ABOVE _________________________________ -->

    <div class='container section-one-position cont-colour'>
        <hr />
        <div class='section-one'>
        <h1>Projects List</h1>
        </div>
        <hr />
    </div>

    <br />
    <div class='full-container'>
    <!-- DISPLAY THE TABLE FROM DATABASE -->
     <?php
        ini_set("display_errors", 1);
        ini_set("display_startup_errors", 1);
        error_reporting(-1);
        require_once("../DAL/db_functions.php");


    if($display == true)
    {
        //Run query on branch table
        readQuery("D_Project");
        //readQuery("D_Projects");


    //If there are any details in branch table continue

        if($numRecords === 0){
            echo "<p>No Branches Found!</p>";
        }   
        else{
            $arrRows = NULL;

            //Create table and headings
            echo "<table id='dalton' border='0'>";
            echo "<tr>";
            // echo "<th>Prospect_No</th>";
            echo "<th>Project_No</th>";
            echo "<th>Project_Name</th>";
            echo "<th>Project_Description</th>";
            echo "<th>Project_Manager</th>";
            echo "<th>Start_Date</th>";
            // echo "<th>Phone</th>";
            echo "<th>Finish_Date</th>";
            echo "<th>Budget</th>";
            echo "<th>Cost_To_Date</th>";
            echo "<th>Tracking_Statement</th>";
            echo "<th>Client_No</th>";
            echo "<th></th>";


            //echo "<th>Email</th>";

            echo "</tr>";

            while($arrRows = $stmt->fetch(PDO::FETCH_ASSOC)){
                echo "<tr>";
                // echo "<td>".$arrRows['Consultant_Id']."</td>";
                echo "<td>".$arrRows['Project_No']."</td>";
                echo "<td>".$arrRows['Project_Name']."</td>";
                echo "<td>".$arrRows['Project_Description']."</td>";
                echo "<td>".$arrRows['Project_Manager']."</td>";
                echo "<td>".$arrRows['Start_Date']."</td>";
                // echo "<td>".$arrRows['Home_Phone']."</td>";
                echo "<td>".$arrRows['Finish_Date']."</td>";
                echo "<td>".$arrRows['Budget']."</td>";
                echo "<td>".$arrRows['Cost_To_Date']."</td>";
                echo "<td>".$arrRows['Tracking_Statement']."</td>";
                echo "<td>".$arrRows['Client_No']."</td>";



                echo "<td><a href='../DAL/edit_Project.php?ID=$arrRows[Project_No]'>Edit</a>";
                echo "<br /><a href='../DAL/delete_confirm.php?TYPE=Consultant&amp;ID=$arrRows[Project_No]'>Delete</a></td></tr>";

            }
            echo "</table>";

        }
    }
    else{
       echo "<p>Please enter your login code to view our list of consultants</p>"; 
    }

    ?>
    <br />
    </div>
    <div class='container section-one-position cont-colour'>
            <?php echo "<form action='../DAL/add_branch.php' method='post'>";
            echo "<input type='submit' value='Add a consultant' />";
            echo "</form>";

            echo "<p></P><P>$numRecords Records Returned</P>";?>
    </div>

    </main>
    <?php include "footer.php"; ?>