markis Posted October 26, 2007 Share Posted October 26, 2007 OK, this is strange, I know. Let's just approach it as a learning exercise for now. Here's what I want to happen: 1. Page loads. There's an image in the page, of a random size. This size will be different every time the page loads. 2. JS finds the size of the image - easy enough for JS, but tough for PHP since the image will have to load before the size can be found. (Right?) 3. JS somehow passes the size (width and height) of the image to some PHP function (This is the tough part) 4. PHP returns a third number, some function of the first two. JS uses it, and goes on its merry little way. Here's another thing - the PHP function (page, whatever) will only process input from some specific URL - ie, some third party could not use a parallel JS to accomplish the same task. Also, the whole works should happen without any user input. If this outside the scope of what's possible, just reply "impossible" and move on to more useful things. Thanks in advance, - markis. Quote Link to comment https://forums.phpfreaks.com/topic/74917-can-you-run-a-php-script-using-js-i-know-its-weird/ Share on other sites More sharing options...
premiso Posted October 26, 2007 Share Posted October 26, 2007 You want to look into using AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/74917-can-you-run-a-php-script-using-js-i-know-its-weird/#findComment-378787 Share on other sites More sharing options...
markis Posted October 26, 2007 Author Share Posted October 26, 2007 OK, I see. That's exactly what I'm looking for, but here's one more question - I see how to make a request to the server by placing my variables in the URL with JS, but how do I make sure this request cannot be replicated by any other than the page itself? Thanks for turning me on to this. I didn't know that the heck AJAX was before today! Quote Link to comment https://forums.phpfreaks.com/topic/74917-can-you-run-a-php-script-using-js-i-know-its-weird/#findComment-378916 Share on other sites More sharing options...
premiso Posted October 26, 2007 Share Posted October 26, 2007 There are a few different ways, but really, the ajax portion should not contain sensitive data in itself. One way to verify it is by using session and storing a hash that is randomly generated each page call and check that the hash is correct. Quote Link to comment https://forums.phpfreaks.com/topic/74917-can-you-run-a-php-script-using-js-i-know-its-weird/#findComment-378921 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.