mardi 18 août 2020

PHP check if isset one of the two [duplicate]

I am trying to check both inputs but when only one of the two is set it should give TRUE. when both are empty it should give a error.

      //check if post image upload or youtube url isset
      $pyturl = $_POST['post_yturl'];
      if (isset($_FILES['post_image']) && isset($pyturl)) {     
        if (empty($_FILES['post_image']['name']) or empty($pyturl)) {
          $errors = '<div class="error2">Choose a news header.</div>';

         } else {   
          //check image format                                                                                                    
           $allowed = array('jpg','jpeg','gif','png'); 
           $file_name = $_FILES['post_image']['name']; 
           $file_extn = strtolower(end(explode('.', $file_name)));
           $file_temp = $_FILES['post_image']['tmp_name'];
           

Tried multiple things but it doesnt want to work as i want.

Aucun commentaire:

Enregistrer un commentaire