when i update any other filed like name and id images becomes blank automatically in php? - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Wednesday, June 9, 2021

when i update any other filed like name and id images becomes blank automatically in php?

when every time i update any fileds in table like (name and id) while i am not updating image becomes blank automatically in php and also in database table! foreg:i change only name dj to jd
on display page image get blank automactically can anyone please help me with this php code!! enter image description here enter code here

<?php
$link=mysqli_connect("localhost","root","","appoitement");
if(isset($_REQUEST["e1"]))
    {
    $id1=$_REQUEST["id"];
    $v1=$_REQUEST["t1"];
    $v2=$_REQUEST["t2"];
    $v3=$_REQUEST["t3"];
    $v4=$_REQUEST["t4"];
    
    $fn=time().$_FILES["ph"]["name"];              
$qry2="update doctorregistration set name='$v1',mobile='$v2',email='$v3',age='$v4',photo='$fn' where id=".$id1;
    mysqli_query($link,$qry2);

if($_FILES["ph"]["size"]>0)
{
    move_uploaded_file($_FILES["ph"]["tmp_name"],"upload/$fn"); 
}
    header("location:profile.php");
}
        $qry="select * from doctorregistration where id=".$_SESSION["id"];
         $result=mysqli_query($link,$qry);
        if(mysqli_affected_rows($link)>0){
            $row=mysqli_fetch_assoc($result);
?>
        <form method="POST" enctype="multipart/form-data">
                                        
        <input type="hidden" name="id" value="<?php echo $row["id"]; ?>"><br>   
        name::  <input type="text" name="t1" value="<?php echo $row["name"]; ?>"><br>
        mobile::    <input type="text" name="t2" value="<?php echo $row["mobile"]; ?>"><br>
        email::<input type="text" name="t3" value="<?php echo $row["email"]; ?>"><br>
        age::<input type="text" name="t4" value="<?php echo $row["age"]; ?>"><br>   
        Photo:: <input type="file" name="ph" value="<?php echo $row["photo"]; ?>"><br>
         <input type="submit" name="e1" value="update">
        </form>
         <?php
                }
        ?>
        <?php
               $link=mysqli_connect("localhost","root","","appoitement");
                $qry="select * from doctorregistration where id=".$_SESSION["id"];
                $result=mysqli_query($link,$qry);
                if(mysqli_affected_rows($link)>0)
                {
                $i=0;
                while($row=mysqli_fetch_assoc($result))
                {   
                 ?>
<hr>
<h2 class="text-center">Doctor</h2>
<hr>

<table class="table table-borderless" style="align:center">
  <tbody> 
    <tr>
      <th class="text-center" scope="col">Name</th>
      <td class="text-center"scope="col"><?php echo $row['name'];?></td>
    </tr>
    <tr>
      <th class="text-center" scope="col">email</th>
      <td class="text-center"scope="col"><?php echo $row["email"] ?></td>
    </tr>
    <tr>
      <th class="text-center" scope="col">Contact Number</th>
      <td class="text-center"scope="col"><?php echo $row['mobile'];?></td>
    </tr>
    <tr>
      <th class="text-center" scope="col">Age</th>
      <td class="text-center"scope="col"><?php echo $row['age'];?></td>
    </tr>   
    <th class="text-center" scope="col">photo</th>
      <td class="text-center"scope="col"><img src="upload/<?php echo $row["photo"]; ?>"></td>
    </tr>
  </tbody>
 </table>


 <?php
$i++;}
}
?> 


source https://stackoverflow.com/questions/67892680/when-i-update-any-other-filed-like-name-and-id-images-becomes-blank-automaticall

No comments:

Post a Comment