Jump to content

Recommended Posts

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! 

Link to comment
https://forums.phpfreaks.com/topic/292842-help-simple-php-code/
Share on other sites

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 by hansford

 

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 by fabmsg

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 by Ch0cu3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.