• Hello all,
    Im trying to inclue an additional php code to the header page that will allow a page redirect on a button click,

    Into the header page in including the follwoing:

    [CODE]
    <?
    if($_POST[‘submitmain1_x’]>0 || $_POST[‘submitmain1_y’]>0){

    header(“Location: https://www.google.co.uk&#8221;);

    exit();
    }
    ?>
    [/CODE]

    AND

    [CODE]
    <form method=post action=<?php echo $_SERVER[‘PHP_SELF’]; ?> name=”myform” id=”myform”>
    <input type=image src=”./../images/signin.jpg” alt=’start search’ name=”submitmain1″ id=”submitmain1″ style=”margin-left:160px; margin-top:5px”>
    </form>
    [/CODE]

    Therefore, when the button is clicked, I would like to be able to redirect to google.co.uk.

    However, im getting the follwoing error:
    “Warning: Cannot modify header information – headers already sent by (output started at D:\best-mobile-contracts.co.uk\wwwroot\blog\wp-content\themes\default\header.php:3)”

    Any id3eas where im going wrong/ Am I inseting the php rediret code into the wrong php file (header.php)?

    Cheers for any help

Viewing 1 replies (of 1 total)
  • The header command has to be the very first thing sent to the browser… If any output has already been sent then a header will have gone with it…
    I can’t remember if anything is sent to the browser prior to the header.php file, but I don’t think it is (I’ll check later – at work at the moment) but one thing to make sure is that you don’t have any white space before the header command in your script…

Viewing 1 replies (of 1 total)
  • The topic ‘problem redirecting from header.php’ is closed to new replies.