-1

I'm using a which contains a display name and an integer value in a form. (Submit button name = choose_page

When I click the submit button of that form, I want to redirect to a page with values.

I don't see what I'm missing.

if(isset($_POST['choose_page'])) {
    $id = (int)$_POST['select_edit_page'];
 header( 'Location: http://mysite.com/admin/editor.php?page='+$id);
    } ?>



<form name="pagina_post" method="post" action="/admin/editor.php">
<select name="select_edit_page" id="pagina1">
<option value='0' >index.php
    </option><option value='1' >foo2.php
    </option><option value='2' >bar.php
    </option><option value='5' >foo.php
    </option><option value='8' >bla.php
    </option><option value='9' >links.php
    </option><option value='10' >foooo.php
    </option></select>
<input type="submit" value="Select" name="choose_page">
</form>

I'm receiving the error that headers are already sent. How can I fix this?

Thanks in advance.

Rob
  • 3,556
  • 2
  • 34
  • 53
  • Post the full HTML code and check is there any space before the first opening php tag ie php – Samy Feb 26 '13 at 10:30
  • You ask here before debugging? That's sad. Anyway use dot notation instead of plus. . -> + – iiro Feb 26 '13 at 10:31
  • Check this link, it explains this topic in detail : http://stackoverflow.com/questions/8028957/headers-already-sent-by-php – Prasanth Bendra Feb 26 '13 at 10:33

2 Answers2

3

change this

 header( 'Location: http://mysite.com/admin/editor.php?page='+$id);

to

header( 'Location: http://mysite.com/admin/editor.php?page=' . $id);
exit();                                                      ^ // concatenation problem 
Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
  • This does not solve my headers already sent error. Is there a workaround for this? – Rob Feb 26 '13 at 10:30
0

try this

header( 'Location: http://mysite.com/admin/editor.php?page=$id');
Devang Rathod
  • 6,650
  • 2
  • 23
  • 32
  • 2
    This won't work in single quotes. You have to use double quotes if you want the variables within the string to be evaluated. Otherwise it will just output $id (as a string, not as the actual value of `$id`). – Quasdunk Feb 26 '13 at 10:32