Jump to content

Problems with POST request


Svane

Recommended Posts

Hi everyone

 

Im newbie, so sorry for what I think is a total basic question. But I really cant get the value out of my POST request. I POST the data from my Arduino, and try to catch it in PHP. Below I have the PHP code: 

 

If i set  

 

$current .= $social;

 

No value is printet in my txt file.

 

If I set

 

$current .= $roughHTTPPOST;

 

This value is put into the txt file:

 

social=1111111111&temp1=22&hum1=46

 

So it seems like I dont get value in here: $social = $_POST['social'];

 

Can someone help me?

<?php
   	
        $social = $_POST['social'];
	$temp1 = $_POST['temp1'];
	$hum1 = $_POST['hum1'];
		
	$file = 'test.txt';
	
	// Open the file to get existing content
	$current = file_get_contents($file);
	
          $roughHTTPPOST = @file_get_contents('php://input'); 

$current .= $social;

// Write the contents back to the file
file_put_contents($file, $current);

?>
Link to comment
Share on other sites

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.