how to retain when update files in php?
My Script is here:

 <?php
                        if($_POST['updatesitesettings'])
                            {       

                             $target = "uploads/2015/"; 
                             $target = $target . basename($_FILES['profile']['name']); 
                             $ok=1; 
                             move_uploaded_file($_FILES['profile']['tmp_name'], $target);
                             if($target == "stored/")
                             {
                             $target = "Attachment is Empty";                           
                             }

                            $site_name  = $_POST['site_name']; 
                            $site_description  = $_POST['site_description'];
                            $site_tag_line  = $_POST['site_tag_line']; 
                            $contact_email_address  = $_POST['contact_email_address'];
                            $contact_phone_number  = $_POST['contact_phone_number'];
                            $notification_time  = $_POST['notification_time'];
                            $meta_keywords  = $_POST['meta_keywords'];
                            $meta_description  = $_POST['meta_description']; 
                            $currency_code  = $_POST['currency_code'];
                            $currency_symbol  = $_POST['currency_symbol']; 
                            $show_map  = $_POST['show_map'];
                            $copyrights_info  = $_POST['copyrights_info']; 
                            $updated_date = date('m/d/Y h:i:s a', time());


                        $person = $_GET['admin_id'];                        
                        $updatesett = $conn->prepare("UPDATE sitesettings SET 
                        site_name=:site_name,
                        site_description=:site_description,
                        site_tag_line=:site_tag_line,
                        contact_email_address=:contact_email_address,
                        contact_phone_number=:contact_phone_number,
                        notification_time=:notification_time,
                        meta_keywords=:meta_keywords,
                        meta_description=:meta_description,
                        currency_code=:currency_code,
                        currency_symbol=:currency_symbol,
                        show_map=:show_map,
                        copyrights_info=:copyrights_info,
                        site_logo=:site_logo,
                        updated_date=:updated_date
                        where person_row_id = :person_row_id                        
                        ");
                        $updatesett->bindParam(':site_name', $site_name, PDO::PARAM_STR);
                        $updatesett->bindParam(':site_description', $site_description, PDO::PARAM_STR);
                        $updatesett->bindParam(':site_tag_line', $site_tag_line, PDO::PARAM_STR);
                        $updatesett->bindParam(':contact_email_address', $contact_email_address, PDO::PARAM_STR);
                        $updatesett->bindParam(':contact_phone_number', $contact_phone_number, PDO::PARAM_STR);
                        $updatesett->bindParam(':notification_time', $notification_time, PDO::PARAM_STR);
                        $updatesett->bindParam(':meta_keywords', $meta_keywords, PDO::PARAM_STR);
                        $updatesett->bindParam(':meta_description', $meta_description, PDO::PARAM_STR);
                        $updatesett->bindParam(':currency_code', $currency_code, PDO::PARAM_STR);
                        $updatesett->bindParam(':currency_symbol', $currency_symbol, PDO::PARAM_STR);
                        $updatesett->bindParam(':show_map', $show_map, PDO::PARAM_STR);
                        $updatesett->bindParam(':copyrights_info', $copyrights_info, PDO::PARAM_STR);
                        $updatesett->bindParam(':site_logo', $target, PDO::PARAM_STR);
                        $updatesett->bindParam(':updated_date', $updated_date, PDO::PARAM_STR);

                        $updatesett->bindParam(':person_row_id', $person, PDO::PARAM_INT);
                        $updatesett->execute();

                        echo "<div  align='center'><label class='control-label' for='inputError' style='color:red;'>User Profile Updated Successfully</label></div>";
                        }
                        ?>
                        <div class="panel-body">
                            <div class="table-responsive">
                            <?php
                            $display = $conn->prepare("Select * from sitesettings where person_row_id = :person_row_id");
                            $display->bindParam(':person_row_id', $adminid);
                            $display->execute();
                            $siteres = $display->fetch();
                            $rowc = $display->rowCount();
                            //echo $rowc;
                            //echo $adminid;
                             ?>
                                <form role="form" id="selectForm" action="<?php echo $_SERVER['PHP_SELF']; ?>?admin_id=<?php echo $adminid; ?>" method="post" enctype="multipart/form-data">
                                    <table width="100%">
                                    <tr valign="top">
                                    <td>
                                        <div class="form-group">
                                            <label>Site Name</label>
                               <input class="form-control" type="text" name="site_name"  value="<?php echo $siteres['site_name']; ?>" style="width:400px;" >
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td>
                                     <td>
                                        <div class="form-group">
                                            <label>Site Description</label>
                                            <textarea class="form-control" type="text" name="site_description" style="width:400px;"  ><?php echo $siteres['site_description']; ?></textarea>
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td>                                     
                                     </tr> 
                                     <tr valign="top">
                                    <td>
                                        <div class="form-group">
                                            <label>Site Tagline</label>
                               <input class="form-control" type="text" name="site_tag_line"  value="<?php echo $siteres['site_tag_line']; ?>" style="width:400px;" >
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     <td>
                                        <div class="form-group">
                                            <label>Contact Email</label>
                               <input class="form-control" type="text" name="contact_email_address"  value="<?php echo $siteres['contact_email_address']; ?>" style="width:400px;" >
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     </tr>
                                     <tr valign="top">
                                    <td>
                                        <div class="form-group">
                                            <label>Contact Phone Number</label>
                               <input class="form-control" type="text" name="contact_phone_number"  value="<?php echo $siteres['contact_phone_number']; ?>" style="width:400px;" >
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     <td>
                                        <div class="form-group">
                                            <label>Notification Time</label>
                               <input class="form-control" type="text" name="notification_time"  value="<?php echo $siteres['notification_time']; ?>" style="width:400px;" >
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     </tr>
                                     <tr valign="top">
                                    <td>
                                        <div class="form-group">
                                            <label>Meta Keywords</label>
                               <textarea class="form-control" type="text" name="meta_keywords" style="width:400px;" ><?php echo $siteres['meta_keywords']; ?></textarea>
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     <td>
                                        <div class="form-group">
                                             <label>Meta Description</label>
                               <textarea class="form-control" type="text" name="meta_description" style="width:400px;" ><?php echo $siteres['meta_description']; ?></textarea>
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     </tr>
                                     <tr valign="top">
                                    <td>
                                        <div class="form-group">
                                            <label>Currency Code</label>
                               <input class="form-control" type="text" name="currency_code"  value="<?php echo $siteres['currency_code']; ?>" style="width:400px;" >
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     <td>
                                        <div class="form-group">
                                            <label>Currency Symbol</label>
                               <input class="form-control" type="text" name="currency_symbol"  value="<?php echo $siteres['currency_symbol']; ?>" style="width:400px;" >
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     </tr>
                                     <tr valign="top">
                                    <td>
                                        <div class="form-group">
                                            <label>Show Map</label>
                               <input class="form-control" type="text" name="show_map"  value="<?php echo $siteres['show_map']; ?>" style="width:400px;" >
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     <td>
                                        <div class="form-group">
                                            <label>Copyrights Info</label>
                               <textarea class="form-control" type="text" name="copyrights_info" style="width:400px;" ><?php echo $siteres['copyrights_info']; ?></textarea>
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 
                                     </tr>
                                     <tr valign="top">
                                    <td>
                                        <div class="form-group">
                                            <label>Site Logo</label>
                                            <?php 

                                            $_SESSION['site_logo'] =  $siteres['site_logo']; 

                                            ?>
                               <input class="form-control" type="file" name="profile"  value="<?php echo $_SESSION['site_logo']; ?>" accept="image/jpeg" style="width:400px;" ><img src="<?php echo $_SESSION['site_logo']; ?>" width="100" height="100">
                                           <!-- <p class="help-block">Example block-level help text here.</p>-->
                                        </div>
                                     </td> 

                                     </tr>


                                     <tr>
                                     <td colspan="2">
                                        <input type="submit" class="btn btn-default" style="background-color:#09F; color:#fff; font-weight:bold;" value="Update Settings" name="updatesitesettings" >
                                        <input type="reset"  class="btn btn-default"  style="background-color: #F00; color:#fff; font-weight:bold;">
                                     </td>
                                     </tr>
                                        </table>
                                    </form>
Member Avatar for diafol

Retain how? There's no explanation with regard to what you want. Dumping 201 lines of markup and code won't help. Just include the relevant bits please, otherwise your post may get ignored. I sugegst you re-post with a cut down version of the above - 80% seems irrelevant to your issue - and explain clearly what you want and what's going wrong. Any errors?

i am not getting value of FileUpLoad after postback and when i edit the fields without selecting file upload.

even i have saved value in session also. but it is not getting value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.