View Full Version : OnCLick Execute command

03-21-2004, 04:37 AM
I need to know how to put:


Into a link so that when i click the link that code is executed. here is the entire code that i have written and it works as soon as i reload the page but i want it to work only if i click the link.

$hs = new COM("HomeSeer.Application");

HomeSeer is an application that i use to control all the lights in my house. the $hs->ExecX10("q20","off","0","0"); tells the HomeSeer application to send out the off command to turn my light at adress q20 off. all this information is not needed but i figured you all may want to know.

03-22-2004, 03:19 AM
Well, at the end of the link, put something like click=true.
So it would look like: http://blah.com/blah.php?click=true

Where blah.php is the page you have the link in.

Then, in your script, simply put:

$click = $_GET['click'];

if ($click) {
$hs = new COM("HomeSeer.Application");

Is that what you were after?

03-22-2004, 01:09 PM
yeah thats it. Is there a way to do the link without putting my adress in.
for example would href="$PHP_SELF?click=true" work or something like that. My code is going to be destributed freely and i dont want to make people change it to their web adress i want it to simply work. I guess i could make an admin page so they would only have to enter their site adress once but will the above work?

I would try it and see if it works but i am at work and dont have a php server running her nor do i have the homeseer dcom

03-22-2004, 01:28 PM
Well, yes you can just put in a relative address, something like:

print "<a href=\"thispage.php?click=true\">";

03-22-2004, 01:35 PM
echo '<a href="' . $_SERVER['PHP_SELF'] . '?click=true">';

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum