温度转换PHP

I have been working on the following simple temperature conversion using HTML and PHP. It is my first attempt at using PHP and I can't seem to get it right.

I am sure there are lots of errors in my code so please be patient!

Here is what I have:

<!DOCTYPE HTML>

<html>
<head> 
      <title>Temp Conversion</title>
      <meta charset="utf-8">
<body>
      <form name="tempConvert" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?>">

<table>
<tr>
    <td>Enter value to convert</td>
    <td><input type="text" name="valueConvert" id="valueConvert" size="15"></td>
</tr>

<tr>
    <td>Convert to:</td>
    <td><select name="convertType" id="convertType" size="1">
               <option disabled> Select a measurement type</option>
               <option value="celsius">Celsius</option>
               <option value="fahrenheit">Fahrenheit</option>
        </select>
    </td>
</tr>

<tr>
    <td><input type="submit" name="btnConvert" id="btnConvert" value="Convert"></td>
    <td><input type="reset" name="btnReset" id="btnReset" value="Reset"></td>
</tr>



</form>

<?php


$valueConvert = $_POST['valueConvert'];
$convertType = $_POST['convertType'];
function tempConvert($valueConvert, $convertType){
    if($convertType == "fahrenheit"){
       $conversion = ((9/5)*$valueConvert) +(32);
   }
    else if ($convertType == "celsius"){
       $conversion = ($valueConvert - 32) * (9/5);
   }
return $conversion;
echo "The initial temperature was $valueConvert. The new temperature is $conversion.";
}
?>

    </body>
</html>

I can't figure out how to pass the users textbox input and dropdown list selection to the php function.

You pretty much have things set up alright. You are not calling the function though.

You echo statement comes after the return statement and will never be executed.

It would be better to do something like this:

<?php

function tempConvert($valueConvert, $convertType)
{
   if($convertType == "fahrenheit"){
       $conversion = ((9/5) * $valueConvert) + (32);
   }
    else if ($convertType == "celsius"){
       $conversion = ($valueConvert - 32) * (5/9);
   }
   return $conversion;
}

$valueConvert = $_POST['valueConvert'];
$convertType = $_POST['convertType'];
$conversion = tempConvert($valueConvert, $convertType);
echo "The initial temperature was $valueConvert. The new temperature is $conversion.";

?>

First of all as i wrote in the comment you forgot to cancel the head tag, and second of all you need to check if the convert button is closed and i fixed your convert function aswell, doesn't know how good it's working, im not pro at php either but hopefully it works :)

<html>
<head> 
      <title>Temp Conversion</title>
      <meta charset="utf-8">
</head>
<body>
      <form name="tempConvert" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?>">

<table>
<tr>
    <td>Enter value to convert</td>
    <td><input type="text" name="valueConvert" id="valueConvert" size="15"></td>
</tr>

<tr>
    <td>Convert to:</td>
    <td><select name="convertType" id="convertType" size="1">
               <option disabled> Select a measurement type</option>
               <option value="celsius">Celsius</option>
               <option value="fahrenheit">Fahrenheit</option>
        </select>
    </td>
</tr>

<tr>
    <td><input type="submit" name="btnConvert" id="btnConvert" value="Convert"></td>
    <td><input type="reset" name="btnReset" id="btnReset" value="Reset"></td>
</tr>



</form>

<?php
 function tempConvert($value, $type){
    if($type== "fahrenheit"){
       return (((9/5)*$value) +(32));
   }
    elseif ($type== "celsius"){
       return (($valueConvert - 32) * (9/5));
   }
}

if (isset($_POST['btnConvert'])) { 
$valueConvert = $_POST['valueConvert'];
$convertType = $_POST['convertType'];

echo "The initial temperature was $valueConvert. The new temperature is tempConvert($valueConvert, $convertType).";
}
?>

    </body>
</html>