$_SESSION['change_text'] = $text_image; // print_r($_POST); echo '<br>'; //print_r($_SESSION); } if (isset($_POST['save'])) { $edit_text_image = new ImageSlider(); $edit_text_image->image_slider_id = $_POST['image_slider_id']; $edit_text_image->image_slider_subtitle = $_POST['image_slider_subtitle']; $edit_text_image->image_slider_title = $_POST['image_slider_title']; $edit_text_image->image_slider_status = $_POST['cb_visibility']; //var_dump($edit_text_image); //print_r($_POST); $edit_text_image->save(); echo "<div class='alert alert-success'> \n <i><strong>Text successfully updated. :)</strong></i>\n </div>"; $new = ImageSlider::get($_POST['image_slider_id']); //print_r($new); $_SESSION['change_text'] = $new; //print_r($_SESSION); } var_dump($_SESSION); ?> <img style="width: 500px; border-radius: 3px;" src="./../img/<?php echo $_SESSION['change_text']->image_slider_url; ?> "> <br><br><br> <h3>Edit text</h3> <br>
<?php /*****************************************************************************************************/ //if clik on button change picture on admin_home.php page if (isset($_POST['change_picture'])) { $text_image = ImageSlider::get($_POST['change_picture']); //insert object $text_image in $_SESSION['change_image'] array $_SESSION['change_image'] = $text_image; //var_dump($_SESSION); } /*****************************************************************************************************/ // if click on button Save on this page if (isset($_POST['save'])) { $text_image = new ImageSlider(); if (!empty($_FILES['fup_image'])) { move_uploaded_file($_FILES['fup_image']['tmp_name'], "./../img/" . $_FILES['fup_image']['name']); $text_image->image_slider_id = $_POST['image_slider_id']; $text_image->image_slider_url = $_FILES['fup_image']['name']; //when data sent from the form we must update data in $_SESSION['change_image'] $_SESSION['change_image'] = $text_image; //insert updated object $text_image in $_SESSION['change_image'] again $text_image->save(); echo "<div class='alert alert-success'> \n <i><strong>Image successfully updated. :)</strong></i>\n </div>"; } //var_dump($_SESSION); } /*****************************************************************************************************/ ?> <br> <h3>Change image</h3>
<?php $text_image = new ImageSlider(); if (isset($_POST['edit'])) { $text_image = ImageSlider::get($_POST['edit']); } if (isset($_POST['save'])) { $text_image->image_slider_id = $_POST['image_slider_id']; $text_image->image_slider_subtitle = $_POST['image_slider_subtitle']; $text_image->image_slider_title = $_POST['image_slider_title']; $text_image->image_slider_status = $_POST['cb_visibility']; $text_image->save(); echo "<div class='alert alert-success'> \n <i><strong>Text successfully updated. :)</strong></i>\n </div>"; } ?> <img style="width: 200px; border-radius: 3px;" src="./../img/<?php echo $text_image->image_slider_url; ?> " <br><br><br> <h3>Edit text</h3> <br> <form action="" method="POST" id="login_form" enctype="multipart/form-data" > <label for="subtitle">Image subtitle:</label> <input class="form-control" id="subtitle" name="image_slider_subtitle" value="<?php echo $text_image->image_slider_subtitle; ?> "> <br>