Ik probeer een conversie pagina te maken met PHP voor temperaturen.
Dit is wat ik tot zover heb (nog niet alles is ingevoerd)
Het probleem is dat wanneer ik op de Convert knop druk, wanneer ik celsius-fahrenheit probeer te berekenen, dat het wel naar de ?p=conv2 pagina gaat, maar ik krijg het antwoord niet te zien. Wat is het probleem??
Dank
Dit is wat ik tot zover heb (nog niet alles is ingevoerd)
PHP:
<?php
if(isset($_GET['p'])){
$page = $_GET['p'];
};
if($page=="conv2"){
// if the Convert button has been clicked
if($_POST['conv']) {
// if from is celsius
if($_POST['froc']=="Cf"){
// if to is fahrenheit
if($_POST['toc']=="Ft"){
$cfa = $_POST['from'] * 1.8;
$_SESSION['ans'] = $cfa + 32;
};
// if to is kelvin
if($_POST['toc']=="Kt"){
$_SESSION['ans'] = $_POST['from'] + 273.15;
};
// if to is rankine
if($_POST['toc']=="Rat"){
$craa = $_POST['from'] * 1.8;
$craaa = $craa + 32;
$_SESSION['ans'] = $craaa + 459.67;
};
// if to is reaumur
if($_POST['toc']=="Ret"){
$_SESSION['ans'] = $_POST['from'] * 0.8;
};
};
// if from is fahrenheit
if($_POST['froc']=="Ff"){
// if to is celsius
if($_POST['toc']=="Ct"){
$cfa = $_POST['from'] - 32;
$_SESSION['ans'] = $cfa / 1.8;
};
// if to is kelvin
if($_POST['toc']=="Kt"){
$fka = $_POST['from'] + 459.67;
$_SESSION['ans'] = $fka / 1.8;
};
// if to is rankine
if($_POST['toc']=="Rat"){
$_SESSION['ans'] = $_POST['from'] + 459.67;
};
// if to is reaumur
if($_POST['toc']=="Ret"){
$fra = $_POST['from'] - 32;
$_SESSION['ans'] = $fra / 2.25;
};
};
//if from is kelvin
if($_POST['froc']=="Kf"){
// if to is celsius
if($_POST['toc']=="Ct"){
$_SESSION['ans'] = $_POST['from'] - 273.15;
};
// if to is fahrenheit
if($_POST['toc']=="Ft"){
$kfaaaa = $_POST['from'] * 1.8;
$_SESSION['ans'] = $kfaaaa - 459.67;
};
// if to is rankine
if($_POST['toc']=="Rat"){
$_SESSION['ans'] = $_POST['from'] * 1.8;
};
// if to is reaumur
if($_POST['toc']=="Ret"){
$fretaaa = $_POST['from'] - 273.15;
$_SESSION['ans'] = $fretaaa * 0.8;
};
};
};
};
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Convert temperatures</title>
</head>
<body>
<h2>Convert temperatures</h2>
<br />
<?php
if($_SESSION['ans']){
?>
Answer: <?php $_SESSION['ans']; ?>
<br />
<?php
};
?>
<form id="form1" name="form1" method="post" action="convert.php?p=conv2">
From: <input type="text" name="from" id="from" /><select name="froc"><option name="Cf">Celsius</option><option name="Ff">Fahrenheit</option><option name="kf">kelvin</option><option name="Raf">Rankine</option><option name="Ref">Reaumur</option></select> To: <select name="toc"><option name="Ft">Fahrenheit</option><option name="Ct">Celsius</option><option name="kt">kelvin</option><option name="Rat">Rankine</option><option name="Ret">Reaumur</option></select> <input type="submit" value="Convert" name="conv" id="conv" /></form>
</html>
Het probleem is dat wanneer ik op de Convert knop druk, wanneer ik celsius-fahrenheit probeer te berekenen, dat het wel naar de ?p=conv2 pagina gaat, maar ik krijg het antwoord niet te zien. Wat is het probleem??
Dank
Laatst bewerkt door een moderator: