-1

I have a PHP script that sending an email after the user click the submit button and it will redirect also to another page. But the header('location: '); is not working. I already remove the whitespace before <?php and after ?>

How to fix this?

User014019
  • 1,215
  • 8
  • 34
  • 66

1 Answers1

2

The redirect in the original version of your question was incorrect. The location provided to the Location header needs to be a full url. When you say:

header('Location: website.com');

the browser interprets that as a redirect to a website.com file on your website. Instead, you will need to provide the full url, like this:

header('Location: http://website.com');

Additionally, in the error you are getting,

Warning: Cannot modify header information - headers already sent by (output started at .../class.wp-styles.php:127) in .../_resumeForm.php on line 248

is an indication that you've already started to output content to the browser. You can not set headers after you have already started to output content. class.wp-styles.php:127 is the location in the code that actually output content, but most likely you are calling that code (directly or indirectly) from somewhere else.

In order to fix the error, you will have to figure out where the output is being started, and stop it from happening there. For more suggestions on just how to do that, see the answer to the question that this one has been marked a duplicate of.

Community
  • 1
  • 1
jbafford
  • 5,528
  • 1
  • 24
  • 37
  • This is true, but you'd still expect it to redirect to [currentUrl]/website.com, rather than not work at all (edit: the "not working" part I have *assumed* means there's no redirect at all - the question is unclear) – scrowler Jan 27 '16 at 02:11
  • even i have that http: still not working – User014019 Jan 27 '16 at 02:15
  • @User014019 Then you have some other problem, *in addition* to that, and your best bet is to turn on error reporting and see if you're getting an error, and then address the error you're also getting.. – jbafford Jan 27 '16 at 02:16
  • @User014019 **define** not working exactly –  Jan 27 '16 at 02:16
  • @jbafford and dagon, please see updated question – User014019 Jan 27 '16 at 02:18
  • @User014019 I think you're missing the integral part of your error message, that's saying *where* output had already started. – jbafford Jan 27 '16 at 02:19
  • @jbafford i post now the whole warning, please see the updated post again – User014019 Jan 27 '16 at 02:36