看到update.php时出现空白页或空白页

时间:2017-01-09 09:08:57

标签: php

UPDATE.php

<?php 
    include('DB.php');
    if(isset($_GET['id'])){
        $id=$_GET['id'];
        if(isset($_POST['update'])){
           $name=mysqli_real_escape_string($link,$_POST["ename"]);
           $email=mysqli_real_escape_string($link,$_POST["eemail"]); 
           $enpassword=mysqli_real_escape_string($link,$_POST["epassword"]);
           $dateofbirth=mysqli_real_escape_string($link,$_POST["edateofbirth"]);
           $mobile=mysqli_real_escape_string($link,$_POST["emobile"]);
           $presentaddress=mysqli_real_escape_string($link,$_POST["epresentaddress"] );
           $drivinglicense=mysqli_real_escape_string($link,$_POST["edrivinglicense"]);

           if(mysqli_query("UPDATE hrmsinfo SET emp_name=$name,emp_email=$email,emp_password=$enpassword,emp‌​_dob=$dateofbirth,em‌​p_phno=$mobile,emp_a‌​ddress=$presentaddress,emp_proof=$drivin‌​glicense WHERE emp_id='$id'")){
               $msg="Successfully Updated!!";
               header('Location:VIEW.php');
           }
           else{
               $msg="Unsucessfull!!";
           }
       }
    }  //update ends here
    ?>

当我尝试使用以下编辑代码执行此更新代码时,它显示空白页面帮助我

以下是完全执行的编辑代码,但更新不起作用,帮助我在哪里停留

<?php 

//error_reporting(0);
include("DB.php");
if(isset($_GET['id'])){
     $id=$_GET['id'];
     $sql="SELECT * FROM hrmsinfo WHERE emp_id='$id'";
     $sqll=mysqli_query($link,$sql);
     while($profile=mysqli_fetch_array($sqll)){
         $username=$profile['emp_name'];
         $usermail=$profile['emp_email'];
         $userdob=$profile['emp_dob'];
         $usermobile=$profile['emp_phno'];
         $useraddress=$profile['emp_address'];
         $userproof=$profile['emp_proof'];
?>

<div>

<form action="UPDATE.php" method="post" name="insertform">


       <div class="form-group">
                  <div class="row">
                    <div class="col-xs-3">Name:</div>
                    <div class="col-xs-4"><input type="text" class="form-control" name="ename" placeholder="Enter Name" value="<?php echo $username; ?>" id="inputid"></div>
                  </div>
                </div>



                <div class="form-group">
                  <div class="row">
                    <div class="col-xs-3">Email:</div>
                    <div class="col-xs-4"><input type="text" class="form-control" name="eemail" placeholder="Enter Email" value="<?php echo $usermail; ?>" id="inputid"></div>
                  </div>
                </div>

                <div class="form-group">
                  <div class="row">  
                    <div class="col-xs-3">Password:</div>
                    <div class="col-xs-3"><input type="password" class="form-control" name="epassword" id="inputid" placeholder="Enter Password" id='input_id'></div>
                    <div class="col-xs-3"><input type="password" class="form-control" name="epassword" id="inputid" placeholder="Re-Enter Password" id='input_id'></div>
                    <div class="col-xs-3">
                    <div class="checkbox"><input type="checkbox"> Auto Generate</div>
                    </div>
                  </div>
                </div>

                <div class="form-group">
                  <div class="row">
                    <div class="col-xs-3">Date Of Birth:</div>
                      <div class="col-xs-5">
                        <div class="input-group date">
                        <div class="input-group-addon">
                          <i class="fa fa-calendar"></i>
                            </div>
                        <input type="date" class="form-control pull-right" name="edateofbirth" value="<?php echo $userdob; ?>" id="inputid">
                      </div>
                    </div>
                  </div>
                </div>








      <div class="form-group">
                  <div class="row"> 
                    <div class="col-xs-3">Mobile Number:</div>
                    <div class="col-xs-5">
                      <input type="text" class="form-control" placeholder="Enter Mobile" name="emobile" value="<?php echo $usermobile; ?>" id="inputid">
                    </div>
                  </div>
      </div>



              <div class="form-group">
                  <div class="row"> 
                    <div class="col-xs-3">Address:</div>
                      <div class="col-xs-5"> 
                      <textarea class="form-control" rows="3" placeholder="Enter Address"  name="epresentaddress" value="<?php echo $useraddress; ?>" id="inputid"></textarea>
                    </div>
                  </div>
                </div>





      <div class="form-group">
                  <div class="row"> 
                    <div class="col-xs-3">Proof:</div>
                     <div class="col-xs-5"> 
                      <input type="text" class="form-control" placeholder="Enter Proof"  name="edrivinglicense" value="<?php echo $userproof; ?>" id="inputid">
                    </div>
                  </div>
                </div>




      <div class="form-group">
        <div class="row"> 
          <div class="col-xs-3"></div>
            <div class="col-xs-5">
              <input type="submit" name="update" value="Update" id="inputid1" />
            </div>
          </div>
        </div>


  </form>

</div>

<?php } } ?>

如果我被困在这里或者我犯了错误,请帮助我正确指导

1 个答案:

答案 0 :(得分:0)

根据你的代码,你提出了一个条件,即

if(isset($_GET['id']))
    {
     .....
}

但是在html表单中你没有传递任何id字段添加id字段并尝试你的条件将验证和更新将工作。 只需添加一个字段,如下所示..剩余相同。

    <form action="UPDATE.php?id=<?php echo $id; ?>" method="post" name="insertform">
    <input type="hidden" name="id"  value="<?php echo $id; ?>" >
   ...............
.................
</form>

注意:在HTML页面中,字段ID应该是唯一的。