Jump to content

Recommended Posts

Hi, I am not asking for code, If you provide it thank you but I am happy to do the work myself I am more after the concept and code snippets.

 

My Goal, I have 2 domains for this I will use www.1.com and www.2.com to make it easy.

 

1.com has a couple lines of javascript and 2 variables 1 being a domain and the other being a unique ID

2.com has a php script which is called by 1.com when the page is loaded (somehow) it will check the Unique ID and the domain that they match in a mySQL database and if they do to run another javascript script. If it does not to just end itself.

 

The problem I have is I know PHP to an average level but Javascript well below average. I need to know how to run the PHP script from an external site 1.com to run a generic PHP script from 2.com and use the variables from 1.com to check the database at 2.com for a match and to either say yes matching display: or not matching deny.

 

If anyone has any ideas on how to do this or something they have done before that would be awesome. I am wanting to to put the javascript on 10 different websites with different variables and for 2.com to just do the checking.

 

for security reasons I need the URL to be checked so if 1.com loads and says the URL is 1.com but infact the user loaded 55.com it needs to be denied so PHP on 2.com needs to know where the request came from which domain...

 

PLEASE HELP :( 

Link to comment
https://forums.phpfreaks.com/topic/282791-php-reading-javascript-file/
Share on other sites

Calling JavaScript from a different site than the page is loaded creates security risks and will be problematic. You can instead create a service on www.2.com that is called either from the JavaScript loaded from the page on www.1.com or have your JavaScript call a PHP page on www.1.com which then calls the service on www.2.com. The service should be a page that accepts the parameters as GET or POST vars.

Hmm, I need something like google analytics do they have variables in javascript and it links to another js document, but I don't know javascript I only know PHP so I can only write PHP. Is there a way to go from 1.com javascript to 2.com javascript to 2.com php? 

 

I need to check a database using PHP and other settings in PHP. I cannot upload a php script to the site I can only use javascript from 1.com but I can do anything from 2.com if I need.

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.