How to remove newlines from header

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Max58kl
    New Member
    • Nov 2007
    • 37

    #1

    How to remove newlines from header

    I have a form with a textarea field.
    Everything is ok until the user submitting the form adds returns characters.

    When return characters are added I get this error

    Warning: Header may not contain more than a single header, new line detected

    This is the part of the script highlighted by the error message.

    header('Locatio n:' . $_action);
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    use str_replace function

    Comment

    • Max58kl
      New Member
      • Nov 2007
      • 37

      #3
      If I submit the form refrencing 'report_pubacce ss' I get this vardump

      Code:
      getarray(2) {
        ["pub_access"]=>
        string(11) "laptop four"
        ["report_pubaccess"]=>
        string(7) "testing"
      }
      If I asign report_pubacces s to a variable $report using string replace
      and send the variable

      Code:
      $report = str_replace("\n", " ", trim($_GET['report_pubaccess']));
      The variable is send however not the text

      Code:
      getarray(2) {
        ["pub_access"]=>
        string(10) "laptop one"
        ["$report"]=>
        string(1) "1"
      }
      Variable version

      Code:
      $_def_soft_id = 1;
      $_def_id = 9876;
      
       $_soft_id = isset($_GET[$report]) ? $_GET[$report] : $_def_soft_id;
      $_id = isset($_GET['pub_access']) ? $_GET['pub_access'] : $_def_id;
      
      $_action = 'report_confirm_pub.php?pub_access=' . $_id . '&$report=' . $_soft_id;
      
      header('Location:' . $_action);

      'report_pubacce ss' version


      Code:
      $_def_soft_id = 1;
      $_def_id = 9876;
      
       $_soft_id = isset($_GET['report_pubaccess']) ? $_GET['report_pubaccess'] : $_def_soft_id;
      $_id = isset($_GET['pub_access']) ? $_GET['pub_access'] : $_def_id;
      
      $_action = 'report_confirm_pub.php?pub_access=' . $_id . '&report_pubaccess=' . $_soft_id;
      
      header('Location:' . $_action);
      Last edited by Dormilich; Nov 9 '11, 06:05 AM. Reason: please use [CODE] [/CODE] tags when posting code

      Comment

      Working...