fabmsg Posted December 2, 2014 Share Posted December 2, 2014 Hi! I'm new to php so, please forgive if this is a really simple question or if it doesn't make sense. I have an www.domain.com web site and then I have an microprocessor at home connected to the internet also hosting and simple page. That page is acessible from the internet. When I'm browising on my www.domain.com i want to add an botton that sends an request to the microprocessor, right now what i do is when the button is clicked, it opens the microprocessor page like : microprocessor.ddns.net/?update=1. How can i make the www.domain.com send the "?update=1" to the microprocessor without the user have to see the microprocessor page. The main purpose is to hide the microprocessor address so it's harder to be hacked.. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
hansford Posted December 2, 2014 Share Posted December 2, 2014 (edited) Instead of using a GET request and having the information in the url, you can do a POST request using a hidden form field. <form name="myform" action="http://www.microprocessor.ddns.net" method="post"> <input type="hidden" name="update" value="1"> <input type="submit" value="submit"> </form> if( !empty($_POST["update"]) ) { $hidden = $_POST["update"]; } Edited December 2, 2014 by hansford Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted December 2, 2014 Share Posted December 2, 2014 Rather than the button submit to directly to microprocessor ip address instead make the button submit to your site. But then use curl to send the request to your microprocessor 1 Quote Link to comment Share on other sites More sharing options...
fabmsg Posted December 2, 2014 Author Share Posted December 2, 2014 (edited) Instead of using a GET request and having the information in the url, you can do a POST request using a hidden form field. <form name="myform" action="http://www.microprocessor.ddns.net" method="post"> <input type="hidden" name="update" value="1"> <input type="submit" value="submit"> </form> if( !empty($_POST["update"]) ) { $hidden = $_POST["update"]; } Thanks! this way is way better. but is it possible to hide the www.microprocessor.ddns.net link in any way? I don't want the user to know the microprocessor web site. Rather than the button submit to directly to microprocessor ip address instead make the button submit to your site. But then use curl to send the request to your microprocessor thanks! from what i've searched this seems what i want, can you just show me an example using the form that hansford gave me? thanks! Edited December 2, 2014 by fabmsg Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted December 2, 2014 Share Posted December 2, 2014 (edited) Basic example using the example code from curl_init <?php if(isset($_POST['send_update'])) { // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://microprocessor.ddns.net/?update=1"); curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); } ?> <form action="" method="post"> <input type="submit" name="send_update" value="Update Microprocessor Button" /> </form> Edited December 2, 2014 by Ch0cu3r Quote Link to comment 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.