Jump to:

23376 Posts in 18295 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Strange Redirect Message appearing!

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 979 Views
  • njprrogers
    Avatar
    Community Member
    23 Posts

    Strange Redirect Message appearing! Link to this post

    Hi,

    I've got a message appearing when I enter a search term and redirect to another page:

    Redirecting to http://localhost/xxx/ie/home/roi-domestic-help-centre/new-faqsearchpage... (output started on C:\xampp\htdocs\xxx\FAQ\code\Tips.php, line 1)

    I do a redirect from the page like this after taking in some form data for Search:
    <code>
       function doSearchResults($data, $form) {
          $url = SEARCHURL;
          Session::set('q', $data['q']);
           Director::redirect($url);
       }
    </code>

    Tips looks like this

    <code>
    <?php
    class Tips extends Page {
       
    public static $db = array(
    "Options" => "Enum('ie, uk')"
    );

       function getCMSFields() {
       $fields = parent::getCMSFields();
          $fields->addFieldToTab(
          "Root.Content.Main",
          new DropdownField(
          'Options',
          'Choose which country this tip applies to:',
          singleton($this->class)->dbObject('Options')->enumValues())
             );

    return $fields;
    }         
    }
    class Tips_Controller extends Page_Controller {

       /**
        * An array of actions that can be accessed via a request. Each array element should be an action name, and the
        * permissions or conditions required to allow the user to access it.
        *
        * <code>
        * array (
        * 'action', // anyone can access this action
        * 'action' => true, // same as above
        * 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
        * 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
        * );
        * </code>
        *
        * @var array
        */
       public static $allowed_actions = array (
       );

    }
    ?>
    </code>

    Thanks in advance,

    Nick

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: Strange Redirect Message appearing! Link to this post

    Normally this occurs if you have whitespace after the ?> tag or before the <?php tag in one of your PHP files. This causes whitespace output so when submitting forms or other things which redirect will cause the warning you mention. This is why one of our guidelines is to avoid using the closing PHP tag.

  • njprrogers
    Avatar
    Community Member
    23 Posts

    Re: Strange Redirect Message appearing! Link to this post

    Hi Willr,

    Thanks once again for your help!

    That's worked eventually... I couldn't find the rogue space or special character but when I re-wrote the php piece by piece it worked fine.

    Cheers,

    Nick

    979 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.