示例#1
0
// Leave the PHP section and create the HTML form:
?>

<h1>Trip Cost Calculator</h1>
<form action="calculator.php" method="post">
	<p>Distance (in miles): <input type="text" name="distance" value="<?php 
if (isset($_POST['distance'])) {
    echo $_POST['distance'];
}
?>
" /></p>
	<p>Ave. Price Per Gallon: <span class="input">
	<?php 
create_radio('3.00');
create_radio('3.50');
create_radio('4.00');
?>
	</span></p>
	<p>Fuel Efficiency: <select name="efficiency">
		<option value="10"<?php 
if (isset($_POST['efficiency']) && $_POST['efficiency'] == '10') {
    echo ' selected="selected"';
}
?>
>Terrible</option>
		<option value="20"<?php 
if (isset($_POST['efficiency']) && $_POST['efficiency'] == '20') {
    echo ' selected="selected"';
}
?>
>Decent</option>
	
<!-- Beginning of HTML form -->
<h1>Trip Cost Calculator</h1>
<form action="3.9_calculator.php" method="post">
	<p>Distance (in miles): <input type="text" name="distance" value="<?php 
if (isset($_POST['distance'])) {
    echo $_POST['distance'];
}
?>
" /></p>
    <!-- sets distance to user-submitted info, once it is entered (sticky form) -->
    <p>Avg. Price per Gallon: <span class="input">
    <?php 
create_radio('3.00');
create_radio('4.00');
create_radio('5.00');
?>
    	
    </span></p>
    <p>Fuel Efficiency: <select name="efficiency">
    	<option value="10"
        <?php 
if (isset($_POST['efficiency']) && $_POST['efficiency'] == '10') {
    echo ' selected="selected"';
}
?>
  >Terrible</option>
        <option value="20"
         <?php 
if (isset($_POST['efficiency']) && $_POST['efficiency'] == '20') {
    echo ' selected="selected"';
示例#3
0
    echo $_POST['distance'];
}
?>
" /></p>
  <p>Estimated MPH (optional): <input type="text" name="mph"
     value="<?php 
if (isset($_POST['mph'])) {
    echo $_POST['mph'];
}
?>
" />
  </p>
  <p>Ave. Price Per Gallon: <span class="input">
	<?php 
for ($i = 0, $val = 3.0; $i < 3; $i++, $val += 0.5) {
    create_radio($val);
}
?>
	</span></p>
	<p>Fuel Efficiency: <select name="efficiency">
		<option value="10"<?php 
if (isset($_POST['efficiency']) && $_POST['efficiency'] == '10') {
    echo ' selected="selected"';
}
?>
>Terrible</option>
		<option value="20"<?php 
if (isset($_POST['efficiency']) && $_POST['efficiency'] == '20') {
    echo ' selected="selected"';
}
?>