PHP, JAVASCRIPT, NETSCAPE and IE
| From: | Thomas Martins | Date: | Thu, 26 Oct 2000 09:28:02 +0000 |
| Subject: | PHP, JAVASCRIPT, NETSCAPE and IE | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-22097@lists.php.net to get a copy of this message | ||
Hello there fellow php-coders...
Problem:
On my site, I send SMS (short messages on cellphones), but it is costing
me money. Now I need to check that the function was actually called
from my server, and not from some remote host....
I call a javascript function on the click of the SMS button, that opens
a new window, that use my php file. something like this...
function sms(id, username, desc)
{
wintoopen = "sms.php3?id=" + id + "&username=" + username +
"&desc=" +
desc;
window.open(wintoopen, coords of new window to open...);
}
then in sms.php3 i include another file called sendsms.php3, which has a
php function in it called sendsms($cellphonenum, $msg)
in sendsms i do something like this...
function sendsms($cellphonenum, $msg)
{
global $HTTP_REFERER;
//check that mydomain.co.za is in HTTP_REFERER
$fromwhere = strpos("HTTP_REFERER", "mydomain.co.za");
//if mydomain.co.za is not in the HTTP_REFERER, then exit...
if ($fromwhere == false)
{
echo "Sorry, could not send sms";
exit;
}
//now send the sms....
code that sends sms...
}
Now, in Netscape (as per ususal) this works 100%, but in IE, it fails,
$HTTP_REFERER is a null value. I experimented with IE, and you need to
pass it as one of the arguments from the javascript function, which is
pretty useless to me, sinse any idiot can write his own function like
function sms(hisid, his msg, 'mydomain.co.za')
{
}
If you have any suggestions, please mail me...I am clueless as to what
to do.
Regards
Thomas Martins
aka pinkey