/    Sign up×
Community /Pin to ProfileBookmark

AJAX and php protected files

I have a php code within a php file. I have a slender protection of that file, something like:

[code=php]
if(!defined(‘foo’)){header(‘HTTP/1.0 404 not found’);exit;}
[/code]

Now, this php file has a query function (to a MYSQL D?. It works ok, [I]in a static[/I] manner (as an include). But the moment I try an AJAX request, the code above is activated and no response is sent back to the AJAX object.

Any idea how to protect a php file on which I need to send an AJAX request?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiJun 09.2009 — Which script are you sending the request to? It's impossible to debug really without seeing the code. I don't see any reason from what you have said that an AJAX request or a manual request should behave differently from PHP's point of view.
×

Success!

Help @Kor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...