When I use $_SERVER['HTTP_ORIGIN']
.
echo $_SERVER['HTTP_ORIGIN'] ;
Return Notice: Undefined index: HTTP_ORIGIN in D:\xampp\htdocs\safe\test.php on line 12
What is Wrong?!
When I use $_SERVER['HTTP_ORIGIN']
.
echo $_SERVER['HTTP_ORIGIN'] ;
Return Notice: Undefined index: HTTP_ORIGIN in D:\xampp\htdocs\safe\test.php on line 12
What is Wrong?!
The Origin
header isn't sent by all browsers.
Depending what you're trying to do, another option is to use the Referer
header:
echo $_SERVER['HTTP_REFERER'];
By the way, note that request headers are ultimately controlled by the user, so can't be fully trusted.
:P
just kidding, as this is as bad as asking money to strangers –
Loar :)
–
Loar HTTP_REFERER
as it can be easily spoofed. I'd delete the answer. –
Natter © 2022 - 2024 — McMap. All rights reserved.
What is Wrong?!
Using HTML snippets to display PHP code is wrong. – LoarOrigin
header has not been provided when the page was requested. – Faradmeterif(isset($_SERVER['HTTP_ORIGIN'])){ echo $_SERVER['HTTP_ORIGIN']; }
– Eye