thecard Posted July 7, 2008 Share Posted July 7, 2008 If someone signs up for my site, then they get a piece of code to put at the bottom of their website: Something like this: <? Include(‘www…./…php’); ?> It includes a php file from my site into their site, it basically collects data from their site and stores it in my database and also echoes some output according to this data. My problem: I know that php doesn’t run on all websites, you have to buy special hosting. How can I make it so that the code would run on all websites? Will I have to use JavaScript? I know its possible using javascript because of google adwords and Bitvertiser ads... I'm really confused at the moment, I don't know how to think about solving this problem in the right way. If you can't give me an answer, please point me to a tutorial or something... Thanks for your time! Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/ Share on other sites More sharing options...
ag3nt42 Posted July 7, 2008 Share Posted July 7, 2008 well your right it is probably javascript because it is "supported" by all websites.. however.. your problem then will become wether or not users have it on.. your best bet would be to talk with the users who are implementing this.. and require they use php on their servers.. otherwise.. ya JS.. Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-583952 Share on other sites More sharing options...
mbeals Posted July 7, 2008 Share Posted July 7, 2008 never mind Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-583953 Share on other sites More sharing options...
anon_login_001 Posted July 7, 2008 Share Posted July 7, 2008 Javascript is likely to be the best method - however it depends on what information you're trying to collect, etc. One very basic example would be to simply build a request with the information you need, and format it like an URL Querystring: OS=windows&userID=33& ... And then have your Javascript either use AJAX to request a special page on your site, or to create a new script tag, with the SRC of your special page: Something like: <script language="javascript" src="http://yoursite.com/special.php?QUERYSTRINGHERE The users browser would attempt to get that page from your server, assuming they have Javascript turned on. That page would process the items from the $_GET variables and could store them for you. Sorry for the glossed-over example... ask about the parts you don't understand. Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-583956 Share on other sites More sharing options...
cooldude832 Posted July 7, 2008 Share Posted July 7, 2008 tricky idea would to include an image at the bottom of the site and the image is gdprocessed image that also does a bit of php in the background so they just need <img src="http://www.yoursite.com/outside.jpg?site=52" /> forexample Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-583958 Share on other sites More sharing options...
thecard Posted July 7, 2008 Author Share Posted July 7, 2008 How would I do this in JS? Bad question, I know. I know php and mysql preaty well -> is there away the "include" was in JS and that set off a script on my site collecting data from theirs? Oh sorry -> I don't just want to collect data, I kinda need to print some results of queries too! Ahh. I made a mess of this! Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-583959 Share on other sites More sharing options...
anon_login_001 Posted July 7, 2008 Share Posted July 7, 2008 Sounds like you ought to be looking up some AJAX tutorials. It's easier than it sounds/looks at first. Just take your time, understand it, and do it right. Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-583961 Share on other sites More sharing options...
thecard Posted July 7, 2008 Author Share Posted July 7, 2008 OK. I'll have a good study in the morning. Blimey -> just when I think I'm starting to get the hang of php and mysql I find out I gotta learn another one! Jokes. I love it really. Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-583962 Share on other sites More sharing options...
roopurt18 Posted July 7, 2008 Share Posted July 7, 2008 You don't need AJAX for this. As someone else suggested use an IMG tag. Your client inserts an IMG tag to a script on your page, complete with $_GET arguments. <!-- your client's html code --> <img style="display: none;" alt="Something or other" src="http://www.yoursite.com/clients/img.php?client_id=1&something_else=Larry" /> On your site you create the img.php script: <?php // Grab $_GET['client_id'] and $_GET['something_else'] and do something with them. // doing something with the data... // This is supposed to be an image, so your script should dump out a 1x1 white img header( 'Content-type: image/gif' ); // set more headers as appropriate fpassthru( 'path/to/1x1.gif' ); ?> (edit) If you need to get more fancy, think about creating a web service, which is very easy to do. Do not rely on JavaScript (aka AJAX) solutions as the user can just disable JavaScript. Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-583974 Share on other sites More sharing options...
thecard Posted July 8, 2008 Author Share Posted July 8, 2008 That really is preety genius! Just wondering if I could then echo text on to the user's page through that? f you need to get more fancy, think about creating a web service, which is very easy to do. I Googled Web services. Seems like just what I've been looking for. How does Google Adwords do it? Through Web Servicing? Thanks for all you help. Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-584290 Share on other sites More sharing options...
roopurt18 Posted July 8, 2008 Share Posted July 8, 2008 I can't speak for Google Adwords, but a web service is basically a way for you to create an API to your site that other people can interact with. Amazon provides, or provided at one point, a web service to query book information from their site. If you can find a working example of that or a tutorial on how to interact with it, it will give you a basic idea of what you can accomplish with a web service. As for creating a web service of your own, it takes a little effort but if you have the PHP SOAP extension installed it takes care of most of the work for you. The most difficult part is creating a proper WSDL file to describe the service; there are tools that can create a WSDL file for you but I prefer to make them by hand. I can't really be much more help than that as I'm no expert on interoperability. Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-584567 Share on other sites More sharing options...
thecard Posted July 8, 2008 Author Share Posted July 8, 2008 Thank you. I'm sure I'll work out a way to do it. I think I'll be able to do it without making a web service. Quote Link to comment https://forums.phpfreaks.com/topic/113633-solved-gathering-code/#findComment-584576 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.