Jump to content

Recommended Posts

I'm new here and looking for help with a problem (already tried googling it, though I'm not sure I'm even explaining it correctly).

 

The only file visible to the user is this

<?php
include "../../the-actual-site/index.php";
?>

The rest of the site is behind the "www" folder, and uses includes, get, and session, variables to navigate the pages.

 

 

Now I want to add some javascript to the display pages, but some nasty things are happening when i do, i trimmed everything down to a bare example (just to make sure something else was not interfering), but these problems still persist.

 

So for the example page I have setup the index.php in the www folder the same way, and used the page from this tutorial as a working example.

 

The tutorial pages work fine if laid out as instructed, or renamed/moved around (but not included).

 

 

So the first problem is that that the javascript requires me to expose the "index.php" part of the url to send a get variable. (I trued outputting just the "?var=" part, and it did not work) The production site never exposes this, and while I don't believe it would cause an issue, I would rather keeps things "as-is" than having people freak out over it.

 

The second issues is that the javascript is making the page display twice once it starts working. Another instance of the page is created below the first one (the second is non-functional).

 

 

So first, how can I use js in an include without the page duplicating?

 

And second how do I get javascript to output clean GET variables without showing the "index.php" part?

Link to comment
https://forums.phpfreaks.com/topic/274668-includes-and-javascript/
Share on other sites

Ok, so found some js stuff in the project, and figured out how its done....

 

 

the display pages arent included if the variable from javascript is found.

A simple way to do this in testing was:

if (!isset($_POST['java_var'])

{

//include html

}

 

which works (though to be honest i dont understand it 100%).

 

 

and the get variables, well there are none for the js, its all done in post. (I guess somebody already ran into that issue =p)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.