php - Other variable value null when change new one -


i making admin panel own site.

i have 5 input fields goes post method variable , these variables call image src.

here demo

if input fields fill image links work fine after if l change 1 link other pictures lost.

php & html

<form action="" method="post">  <input type="url" name="img1"/> <input type="url" name="img2"/>  </form>  <?php        if($_server['request_method'] == "post") {         $img1=$_post['img-one'];         $img2=$_post['img-two'];         ?>          <div><img id="admin-image-pack-2" alt="null" src="<?php echo $img1; ?>"/><img id="admin-image-pack-2" alt="null" src="<?php echo $img2; ?>"/> 

check if post $_post['img-one'] not null before assign variable. way if update second value example won't lose first one. same posts.

example:

if (!empty($_post['img-one'])) {       $img1=$_post['img-one'];   } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -