Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OnCLick Execute command

    I need to know how to put:
    Code:
    $hs->ExecX10("q20","off","0","0");
    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.

    Code:
    <html>
    <head></head>
    <body>
    <?php
     $hs = new COM("HomeSeer.Application");
     $hs->ExecX10("q20","off","0","0");
     unset($hs);
    ?>
    </body>
    </html>
    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.

  • #2
    Az`
    Az` is offline
    New Coder
    Join Date
    Mar 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    $click = $_GET['click'];
    
    if ($click) {
    $hs = new COM("HomeSeer.Application");
     $hs->ExecX10("q20","off","0","0");
     unset($hs);
    }
    Is that what you were after?

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Az`
    Az` is offline
    New Coder
    Join Date
    Mar 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, yes you can just put in a relative address, something like:
    Code:
    print "<a href=\"thispage.php?click=true\">";

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    echo '<a href="' . $_SERVER['PHP_SELF'] . '?click=true">';
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •