/    Sign up×
Community /Pin to ProfileBookmark

Checking for access

Hi,

When requiring files, the required files usually have a [i]if(!defined(‘FOO’))[/i] or some other code at the top to check if the file can be accessed. This is so that people can’t directly access the files and break something.

Anyway, lately I’ve been trying out the new web-hype, Ajax. I’ve managed to create a script that updates a news item without having to reload the page. The thing is, I’m accessing this ‘edit.php’ file to make the database changes, but the ‘define’ method as mentioned won’t work. When I define a variable in the first file and then use the XMLHTTPRequest to access another file, the accessed file won’t find the variable defined. Using POST or GET to check for validity also isn’t an option since everyone can see the Javascript files.

So, how are you supposed to know your files are being accessed with XMLHTTPRequest, and thus giving it access?

Thanks.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@HuevoosMay 09.2006 — you don't what I do is create a new file, include the functions lib and just call the function you need for the xm......est

I don't knowo if I'm being clear
Copy linkTweet thisAlerts:
@chazzyMay 09.2006 — So, how are you supposed to know your files are being accessed with XMLHTTPRequest, and thus giving it access?

Thanks.[/QUOTE]


To be honest, I'm not sure what you're asking. Are you trying to find out if a user can access a file or something else? if PHP can access the file, then php will access the file. should have nothing to do with having define in your code, that just checks if a variable/keyword is already defined. you can try to include external resources as well.
×

Success!

Help @SanderK 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.20,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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