This is my first attempt at posting from a form with php. I'm not doing so well with it. I have a form that user enters numbers they received from blood tests 1 and 2 and the days apart the test was done. It calculates the time it takes for hcg (a pregnancy hormone) to double. It also provides a daily increase rate. I did the hcgcalc.php page first and when I write the variables and their values on this page it calculates perfectly but since I need user input I made hcgview.php to hold the form and I'm also trying to have results returned to this page. I've been COMPLETELY unsuccessful at passing the variables or getting them back. I've tried passing through a url and using $_post and I've also tried HTTP POST too. No avail. I'm sure I'm doing something pretty stupid since I'm not a programmer IRL, I only play one on the internet 😃
I wouldn't even mind if I could get all this on one page but I couldn't figure that out either.
Here is code for hcgview.php which holds the form:
<html>
<head>
<title></title>
<meta name="">
<?php include('../menu.php'); ?>
<?php include('hcgcalc.php'); ?>
<?php
chelle_css()
?>
</head>
<body background="/images/mol.gif">
<center><table width="90%" bgcolor="#9EC2E5" cellspacing="0" cellpadding="5" border="0">
<tr colspan="2"><!-- Row 1 -->
<td background="/images/mol.gif">
<?php
chelle_header()
?>
<a href="/"><img src="/images/logo_phpBB.gif" width="300" height="109" alt="Womens-Place" border="0" align="left"></a></td>
<td background="/images/mol.gif"> </td>
</tr>
<tr><!-- Row 2 -->
<td>
<!-- Add content here -->
<form method="POST" name="hcgcalc.php">
<div align="left"><table border="2" bordercolor="#000000"
bordercolordark="#356A6A" bordercolorlight="#5FAFAF">
<tr>
<td><font face="Arial">First HCG Level</font></td>
<td align="right"><font face="Arial"><input
type="text" size="6" name="beta1" ></font></td>
<td><font face="Arial">mIU/mL</font></td>
</tr>
<tr>
<td><font face="Arial">Second HCG Level</font></td>
<td align="right"><font face="Arial"><input
type="text" size="6" name="beta2"
></font></td>
<td><font face="Arial">mIU/ml</font></td>
</tr>
<tr>
<td><font face="Arial">Days Between Tests</font></td>
<td align="right"><font face="Arial"><input
type="text" size="5" name="days"
></font></td>
<td><font face="Arial">days</font></td>
</tr>
<tr><td><input type="submit" value="calculate">
</td></tr>
</table>
</div>
</form><br>
<br>
<?php
dblcalc ()
?>
<br>
<?php
dailyinc ()
?>
</td>
<td> </td>
</tr>
</table></center>
<?php
chelle_header()
?>
<?php
copyright()
?>
</center>
</body>
</html>
Here is the url to see what that returns:
hcgview
Here is hcgcalc.php
<?php
$beta1 = $POST['beta1'];
$beta2 = $POST['beta2'];
$days = $_POST['days'];
function dblcalc ()
{
if (($beta1 > 0) && ($beta2 > 0) && ($beta1 < $beta2) && ($days > 0))
$dbltime = ($days * 24) / (log($beta2/$beta1) / log(2));
echo round($dbltime, 1);
}
function dailyinc ()
{
if (($beta1 > 0) && ($beta2 > 0) && ($beta1 < $beta2) && ($days > 0))
$dayincrate = pow($beta2/$beta1, 1/$days);
echo round ($dayincrate, 2);
}
?>
Any help on this would be appreciated.