473,472 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PHP define not working with jquery load

45 New Member
I have a main file index.php into which iam loading myinnerpage.php. I have defined a variable inside index.php & checks it on myinnerpage.php, but when i load innerpage it shows restricted access, any idea why? following is my code.

index.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     define( '_JEXEC', true ); 
  3. ?>
  4. <div class="mypage">
  5. </div>
  6. <ul>
  7.     <li><a href="#" onclick="loadpages('myiinerpage.php')">about page</a></li>   
  8. </ul>
  9.  
  10. <script type="text/javascript">
  11.     var $jq = jQuery.noConflict();
  12.     function loadpages(page)
  13.     {
  14.         $jq('.mypage').load('myfolder/'+page);
  15.     }
  16.  
  17. </script>
  18.  
and now in the myiinerpage.php which is in the folder myfolder i have the following code.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. defined('_JEXEC') or die('Restricted access');
  3. ?>
  4.  
  5. <div>
  6. my page elements
  7. </div>
  8.  
  9.  

but when i click on the link it shows restricted access. I have loaded jquery too, any idea y this is happening?
Dec 23 '11 #1
3 2590
Dormilich
8,658 Recognized Expert Moderator Expert
that’s because constants are only valid in the current script. what you do is an AJAX request for which the constant is long gone. you would need to use sessions to accomplish that.
Dec 23 '11 #2
charles07
45 New Member
Dear Dormilich

could you please help me use sessions in this particular situation
Dec 27 '11 #3
charles07
45 New Member
guys finally i found a solution, hope this is right, please contribute your ideas

In my main index.php i changed function to this
Expand|Select|Wrap|Line Numbers
  1. function loadpages(page)
  2.     {
  3.         var myvalue = "myvalue ";
  4.         $jq('.mypage').load('myfolder/'+page,myvalue+"="+myvalue);
  5.     }
  6.  
and in the myiinerpage.php i added a piece of code like this
Expand|Select|Wrap|Line Numbers
  1. if($_GET['myvalue '] == '' || $_SERVER['HTTP_REFERER'] == '')die("Access denied");
  2.  
i used $_SERVER['HTTP_REFERER'] just incase someone tries to access the page by directly typing the get value in url
Dec 27 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: P. Adhia | last post by:
Sorry for quoting an old post and probably I am reading out of context so my concern is unfounded. But I would appreciate if I can get someone or Serge to confirm. Also unlike the question asked in...
2
by: Lobb[cz] | last post by:
Hi. I have a problem with running application from windows form application (VB.NET). I'm using Call Shell(path, AppWinStyle.NormalFocus, False) but I need to define working directory 2 (in...
1
by: CL4life | last post by:
I have the following problem: a program, located on drive a known drive (for example lets say drive C:) needs to execute a program on an unknown different drive (a USB device which doesn't have the...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
6
by: aaronkmar | last post by:
Trying to get a loading image to spin while the query is loading. I can get the data div to fade in, but I can't seem to figure out how to get the gif while the query is loading. I'm using two...
1
by: BobBlock | last post by:
The main page ("parent.html") has a link that ajaxloads a page ("page1.html") into a div ("targetdiv") in the main page, like so: parent html: $("#targetdiv").html(loading).load('page1.html');...
1
pradeepjain
by: pradeepjain | last post by:
http://ratingscorner.com/tempcollege Hi i have posted a link above. i load a data from server using .load() function . its working in all browsers . but it does not in IE. is there a coding...
0
by: amskape | last post by:
hi Friends, I need to Upload some files in a Listing , by clicking corresponding Upload link, then a popup window will come with Browse option as Shown in attachment File. My actual need is...
1
by: omar999 | last post by:
hi guys i really dont understand where i am going wrong.I've read countless articles including http://blog.nemikor.com/2009/10/03/using-multiple-versions-of-jquery/ but still having trouble with...
2
by: xiiopao | last post by:
hi there guys im currently working on a project with jquery... the thing is.. i need to change the contents of a div named "sub2" with the contents of "pets.html"... i've read some tutorials and i...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.