By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,335 Members | 2,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,335 IT Pros & Developers. It's quick & easy.

How to remove newlines from header

P: 37
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('Location:' . $_action);
Nov 8 '11 #1
Share this Question
Share on Google+
2 Replies


100+
P: 1,059
use str_replace function
Nov 8 '11 #2

P: 37
If I submit the form refrencing 'report_pubaccess' I get this vardump

Expand|Select|Wrap|Line Numbers
  1. getarray(2) {
  2.   ["pub_access"]=>
  3.   string(11) "laptop four"
  4.   ["report_pubaccess"]=>
  5.   string(7) "testing"
  6. }
If I asign report_pubaccess to a variable $report using string replace
and send the variable

Expand|Select|Wrap|Line Numbers
  1. $report = str_replace("\n", " ", trim($_GET['report_pubaccess'])); 
The variable is send however not the text

Expand|Select|Wrap|Line Numbers
  1. getarray(2) {
  2.   ["pub_access"]=>
  3.   string(10) "laptop one"
  4.   ["$report"]=>
  5.   string(1) "1"
  6. }
Variable version

Expand|Select|Wrap|Line Numbers
  1. $_def_soft_id = 1;
  2. $_def_id = 9876;
  3.  
  4.  $_soft_id = isset($_GET[$report]) ? $_GET[$report] : $_def_soft_id;
  5. $_id = isset($_GET['pub_access']) ? $_GET['pub_access'] : $_def_id;
  6.  
  7. $_action = 'report_confirm_pub.php?pub_access=' . $_id . '&$report=' . $_soft_id;
  8.  
  9. header('Location:' . $_action);

'report_pubaccess' version


Expand|Select|Wrap|Line Numbers
  1. $_def_soft_id = 1;
  2. $_def_id = 9876;
  3.  
  4.  $_soft_id = isset($_GET['report_pubaccess']) ? $_GET['report_pubaccess'] : $_def_soft_id;
  5. $_id = isset($_GET['pub_access']) ? $_GET['pub_access'] : $_def_id;
  6.  
  7. $_action = 'report_confirm_pub.php?pub_access=' . $_id . '&report_pubaccess=' . $_soft_id;
  8.  
  9. header('Location:' . $_action);
Nov 8 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.