Hello there,
I have been trying to learn php for a couple of months now so decided to try to write a small program to test how I am doing.
The form is supposed to allow a user to use the select list box to choose a conversion option; mm to inch or inch to mm, then a text box is displayed bellow to allow the user to enter the size they require converting as well as a submit button which when clicked should use an external php document to process the selection and entry…
I have written this from scratch with very little experience and although Dreamweaver or notepad ++ do not display errors, I cant seem to get my form to process the information.
Here is the HTML:
<!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>Untitled Document</title>
</head>
<body>
<form action="file:///C|/wamp/www/Dynamic_Web_Design_with~_PHP_and_MySQL_Working Files/Chapter04/math_inch_to_mm.php" method="post">
<p>
Select unit of measurement to convert:<br />
<select name="position" size="1">
<option value="mm_select">mm to inches</option>
<option value="inches_select">inches to mm</option>
</select>
</p>
<p>
Please enter the size you want converting:
</p>
<p>
<input type="text" name="measurement_input" value="" />
</p>
<p>
<input type="submit" value="Convert">
</p>
</form>
</body>
</html>
Here is the PHP code:
[php]
mm to inch/inch to mm calculator <?php $mmPerInch == 25.4; $measurement_input = $_POST['measurement_input']; $millimetre = $_POST['mm_select']; $inches = $_POST['inches_select']; $measurement_input * $mmPerInch = $inches_to_mm; $measurement_input / $mmPerInch = $mm_to_inches; if (isset ($_POST ['$millimetre'])){ print "$mm_to_inches"; } else { print "$inches_to_mm"; ; } ?>[/php]
Can anyone see where I have gone wrong and guide me in the right direction please?
Kind regards,
Luke
[font=comic sans ms][/font]