Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

Strange Redirect Message appearing!


Reply


3 Posts   1031 Views

Avatar
njprrogers

Community Member, 23 Posts

7 May 2011 at 5:18am

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

Avatar
Willr

Forum Moderator, 5513 Posts

7 May 2011 at 2:47pm

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.

Avatar
njprrogers

Community Member, 23 Posts

7 May 2011 at 10:49pm

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