28, May 2012

passing values from html/js to remote php script - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: passing values from html/js to remote php script
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: passing values from html/js to remote php script  (Read 2127 times)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« on: Jul 23, 2006, 09:08:56 pm »

hello,

I noticed that there are several script that using an include file inside a javascript tag.

With this file there visitor statistics stored inside a database. How does this happen? is there a point some where I can start?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Jul 23, 2006, 09:14:34 pm »

I am not sure what you are asking here,

You are asking why they usejavascript to store statistics, or how do they do that?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Jul 23, 2006, 09:16:54 pm »

I am not sure what you are asking here,

You are asking why they usejavascript to store statistics, or how do they do that?
yes something like that, they include a remote JS file and inside the JS is written a image tag and this image tag source sends all information like referer, IP address to the script.

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Jul 23, 2006, 09:19:26 pm »

They do that to prevent referer spam, as most bots will not execute javascript, or load images from the page that they are spamming.

The problem is that this technique can cause big overhead to high traffic websites....

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jul 23, 2006, 09:30:43 pm »

I just need a way to use my visitor counter inside a html file...all this stats counter are doing this that way...

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Jul 23, 2006, 09:33:45 pm »

It is easy to do that. You just need to send a header (that the document is an image)

If you want the code for the image header let me know, so I can post it from work tomorrow (I'm @ home now)

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jul 23, 2006, 09:35:07 pm »

... you create an image and your retrieving the header information? how is this called?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #7 on: Jul 23, 2006, 09:37:27 pm »

no you call a php doc like it was an image (eg. <img src=".........php" )

and in the php file you send the header to 'trick' the browser that the file is image.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Jul 23, 2006, 09:39:12 pm »

no you call a php doc like it was an image (eg. <img src=".........php" )

and in the php file you send the header to 'trick' the browser that the file is image.
yes right but how do you retrieve the referer information of the document? Javascript?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #9 on: Jul 23, 2006, 09:42:09 pm »

I am not sure about that, but js is a solution for that.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #10 on: Jul 23, 2006, 09:43:44 pm »

I am not sure about that, but js is a solution for that.
Thanks I will give it a try...

Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #11 on: Jul 23, 2006, 09:44:33 pm »

#offtopic:

I think in two month I'm the richest man here...

Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #12 on: Jul 23, 2006, 11:20:51 pm »

I got it working:

I'm including a JS file with code inside my html file (somewhere inside the body):
Code:
var ref = document.referrer;
document.write("<img src=\"/include/count_visitor_statistics/count_image.php?ref="+ref+"\" border=\"0\" />");

Inside the file "count_image.php" I have acces to these variables and I'm using this code to show a small picture (1px transp. gif)
Code:
<?php
class Count_image extends Count_visitors {

function Count_image() {
$this->referer = (!empty($_GET['ref'])) ? $_GET['ref'] : "";
$this->host "www.".ltrim($_SERVER['HTTP_HOST'], "www.");
$url_parts parse_url($_SERVER['HTTP_REFERER']);
$this->visited_page $url_parts['path'];
$this->db_connect();
}
}
$img_count = new Count_image;
$img_count->delay 1// how often (in hours) a visitor is registered in the database (default = 1 hour)
$img_count->insert_new_visit(); // That's all, the validation is with this method, too.

// code to show a 1px transparent image

header("Content-type: image/gif");
$img fopen("./spacer.gif""r");
fpassthru($img);


This code will be added to the class "Counter & visitor statistics" soon.


I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #13 on: Jul 24, 2006, 09:20:53 am »

Cool Wink

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3381
Tags : php javascript html databases browsers Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: passing values from html/js to remote php script
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 12:28:00 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.