Using WiFiClient to GET data from a .php webpage

Hello, I am trying to collect data from a webpage using an Arduino Uno WiFi rev2 where my code sets the arduino as a client. I can get the HTML contents from the webpage using a GET request, but everything within the <?php ?> brackets is omitted from the GET response.

Anyone have any idea why the GET collects the HTML but omits everything with the php brackets?

My code is meant to do the following:

  1. read a temp and humidity sensor.
  2. POST the readings to a website.
  3. Collect a set temperature from an HTML form on the same website where temp and humidiy were posted.
  4. Use the set temperature for subsequent calculations.

Below is my code so far, and the sensor3.php file.

/*
 */
#include <SPI.h>
#include <WiFiNINA.h>
#include <HttpClient.h>
#include "Adafruit_Sensor.h"
#include "Adafruit_AM2320.h"
Adafruit_AM2320 am2320 = Adafruit_AM2320();
#include "arduino_secrets.h" 
String data;
String temp,hum;

///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;                                // your network key Index number
int status = WL_IDLE_STATUS;                     // the Wifi radio's status
WiFiClient client;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < "1.0.0") {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WEP network, SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, keyIndex, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

  // once you are connected :
  Serial.print("You're connected to the network");
  printCurrentNet();
  printWifiData();
  Serial.println("Adafruit AM2320 Basic Test");
  am2320.begin();
  
}
void loop() {
  delay(10000);
  printCurrentNet();
    
  hum=String(am2320.readHumidity());
  temp=String(am2320.readTemperature());
  data = "temperature=" + temp + "&humidity=" + hum;
  post();
  collect();
}

void printWifiData() {
  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
  Serial.println(ip);
}

void printCurrentNet() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.println(rssi);
}

void post(){
  Serial.println("POSTconnecting...");
  Serial.println(data);
  if (client.connect("proofertemp.000webhostapp.com",80)) {
    Serial.println("POSTconnected");
    client.println("POST /sensor3.php HTTP/1.1");
    client.println("Host:  proofertemp.000webhostapp.com");
    client.println("User-Agent: Arduino/1.0");
    client.println("Connection: close");
    client.println("Content-Type: application/x-www-form-urlencoded;");
    client.print("Content-Length: ");
    client.println(data.length());
    client.println();
    client.println(data);
  } else {
    Serial.println("connection failed");
  }
}

void collect() {
  if (client.connect("proofertemp.000webhostapp.com",80)) {
    Serial.println("COLLECTconnected");
    client.println("GET /sensor3.php HTTP/1.1");
    client.println("Host: proofertemp.000webhostapp.com");
    client.println("Connection: close");
    client.println();
  } 
  else {
    Serial.println("connection failed");
  }
    Serial.println("[Response:]");
    while (client.connected() || client.available())
    {
      if (client.available())
      {
        String line = client.readStringUntil('\n');
        Serial.println(line);
      }
    }
    client.stop();
    Serial.println("\n[Disconnected]");    
}

Here is the sensor3.php code:

<html>
<div>
<p>Temperature : <?php $Temp;?> C</p>
<p>Humidity :  <?php $Humidity;?> %</p>

<form action="result.php" method="post">
<select name="temp">
<option value="75">75</option>
<option value="110">110</option>
</select>
<input type="submit" name="submit" value="Get Selected Values" />
</form>
<?php
if(isset($_POST['submit'])){
$selected_val = $_POST['temp'];  // Storing Selected Value In Variable
echo "You have selected :" .$selected_val;  // Displaying Selected Value
}
?>
<p>Value = <?php $selected_val ?> </p>
</html>

Anyone have any idea why the GET collects the HTML but omits everything with the php brackets?

Point your browser to the same URL, do you get the content between the php brackets? No. That's because the content there is interpreted (executed) by the server. And the PHP code expects other parameters than you provide ('tenp' and 'temperature' is not the same string!).