0

I am trying to update the query and display into the next page. Here is my code,problem is i will get a warning message "Cannot modify header information - headers already sent". Please help.

$id = (isset($_GET['id'])) ? $_GET['id'] : '';
$val = view_data($id);
if (empty($_POST) === false) {
    $title = $_POST["offered"];
    $description = $_POST["description"];
    $id = $_POST["id"];
    $update = update($title, $description, $id);
    if ($update) {
        header("location:hotel2_galery.php");
    }
}

HTML

<form action="hotel2_galery_edit.php" method="post" class="col-sm-4">
   <div class="form-group has-info">
      <input type="hidden" name="id" value="<?php echo $val->offer_id;?>">
      <label class="control-label" for="inputSuccess">Offer title
      </label>
      <input type="text" class="form-control" name="offered" id="offered" value="<?php echo $val->offers_name; ?>">
      <label>Offer Description
      </label>
      <textarea id="description" name="description" class="form-control " rows="3">
      <?php echo $val->offers_description; ?>
      </textarea>
      <br>  
      <button type="submit" class="btn btn-primary">
      <span>UPDATE
      </span>
      </button>
   </div>
</form>
Anik Islam Abhi
  • 25,137
  • 8
  • 58
  • 80
Sheethal hari
  • 129
  • 1
  • 1
  • 17
  • you couldn't get solution like this. you have to show full code. as there is a repetition of headers here. Might be you included the a file that also contains header. – Maha Dev Oct 28 '15 at 05:24
  • 3
    http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php#8028987. you should first understand why its happening. – Athi Krishnan Oct 28 '15 at 05:26

1 Answers1

0

Try

echo "<script>location.href='hotel2_galery.php'</script>";

instead of

header("location:hotel2_galery.php");

This is a temporary fix. If you show us entire code, we may help you further.

Thamilhan
  • 13,040
  • 5
  • 37
  • 59