I need to upload an image and add it to my slideshow and give it related newsTitle in front of my uploaded picture. I'm a new in PHP and trying to learn how to send data from my admin.php file to my index.php file and add more image with a <form> in html.
My problem is that I can upload images but can't get my newsTitle printed to my home page which is index.php.
This is my PHP code in index.php:
<?php
    if (isset($_POST['send_object'])) {
     $file_name = $_FILES['image']['name'];
     $file_type = $_FILES['image']['type'];
     $file_tmp_name = $_FILES['image']['tmp_name'];
     //$newsTitle = $_POST['newsTitle'];
     $newsImage = $_POST['newsImage'];
     echo '<h2><?php echo 'htmlspecialchars($_POST['newsImage']);'';
     echo'<h2'.'>'.htmlspecialchars($newsImage["newsImage"]).'</h2>';
     if (move_uploaded_file($file_tmp_name,"uploader/$file_name")) {
     }
     }
     $folder = "uploader/";
     if (is_dir($folder)) {
     if($handle = opendir($folder)) {
      while (($file = readdir($handle)) != false) {
       if ($file ==='.' || $file=== '..') continue;
        echo '<img class="slider mySlides" width="100" src="uploader/'.$file.'" alt="">';
     }
      closedir($handle);
     }
    }
    ?>
This is my html code in admin.php:
<form action="index.php" method="post" enctype="multipart/form-data">
        <br><br>
        <tr>
          <td>  NewsTitle: </td>
          <td> <input type="text" name="newsTitle" placeholder="newsTitle"> </td>
        </tr>
        <br><br>
        Select image to upload:
        <input type="file" name="image">
        <br><br>
        <br><br>
        NewsText: <textarea name="newsImage" placeholder="newsImage" rows="5" cols="40"></textarea>
        <br><br>
        <input type="submit" value="Send" name="send_object">
    </form>
I'm trying to do this without connection to the database, just to my apache server. I have tried with another global variable $_REQUEST but it didn't work. What I know it can use for $_POST , $_GET and $_COOKIES
 
     
    
'.htmlspecialchars($newsImage["newsImage"]).'
';` that alone should be throwing you a parse error http://php.net/manual/en/function.error-reporting.php and the opening ` echo'` is incorrect.
– Funk Forty Niner Oct 07 '16 at 23:29wich a have class for and then have propertys how it should look
– Oct 09 '16 at 15:37