Some PHP help

I have been trying to figure out what I’m doing and it seems I missing just something very basic. Any help would be greatly appreciated.

[php]

Calories Burned Calculator
<?php
$cyclingStart = $_POST['cyclingStart'];
$cyclingEnd = $_POST['cyclingEnd'];
$swimmingStart = $_POST['swimmingStart'];
$swimmingEnd = $_POST['swimmingEnd'];
$walkingStart = $_POST['walkingStart'];
$walkingEnd = $_POST['walkingEnd'];
$runningStart = $_POST['runningStart'];
$runningEnd = $_POST['runningEnd'];
$tennisStart = $_POST['tennisStart'];
$tennisEnd = $_POST['tennisEnd'];

$totalCycling = ($cyclingStart / $cyclingEnd) * 650 = $totalCalories;
$totalSwimming = ($swimmingStart / $swimmingEnd) * 500 = $totalCalories;
$totalwalking = ($walkingStart / $walkingEnd) * 280 = $totalcalories;
$totalRunning = ($runningStart / $runningEnd) * 700 = $totalCalories;
$totalTennis = ($tennisStart / $tennisEnd) * 290 = $totalCalories;

<link rel="stylesheet" type="text/css" href="sample.css" /></head>
print (" <h1>$lastName, $firstName </h1>");, you burned $totalCalories for $totalCycling minutes,

<p><a href = "calories.html">Calculate another day?</a></p>

?>

[/php]

By the way this is the html that will work with this php.

[php]

Calories Burned Calculator

Calories Burned Calculator

Use military time

<form action = "calories.php" method = "post" >
<p>What is your first name?
<input type = "text" size = "20" name = "firstName" 
	
<p>What is your last name?
<input type = "text" size = "20" name = "lastName" /></p>
	
<img src="baphbike.jpg" width="200" height="200" alt="Baphomet Cycle" />
	
<p>What is your start and end time for your <a href="http://www.active.com/cycling/articles/how-to-look-like-a-cyclist" target="_blank">cycling workouts?</a></p>
<p>Start Time<input type = "text" size = "6" name = "cyclingStart" />
<p>End Time<input type = "text" size = "6" name = "cyclingEnd" /></p>
<p>Start Time<input type = "text" size = "6" name = "cyclingStart1" />
<p>End Time<input type = "text" size = "6" name = "cyclingEnd1" /></p>
	
	
	<img src="bluedevil.jpg" width="200" height="200" alt="swimming devil" />
	
	<p>What is your start and end time for your <a href="http://www.huffingtonpost.com/wicked-good-travel-tips/do-you-swim-in-sludge-ame_b_662131.html" target="_blank">swimming workouts?</a></p>
	<p>Start Time<input type = "text" size = "6" name = "swimmingStart" />
	<p>End Time<input type = "text" size = "6" name = "swimmingEnd" /></p>
	<p>Start Time<input type = "text" size = "6" name = "swimmingStart1" />
	<p>End Time<input type = "text" size = "6" name = "swimmingEnd1" /></p>

Baphomet Walking

	<p>What is your start and end time for your <a href="http://www.kelly-annmaddox.com/2013/02/walking-left-hand-path.html" target="_blank">walking workouts?</a></p>
	<p>Start Time<input type = "text" size = "6" name = "walkingStart" />
	<p>End Time<input type = "text" size = "6" name = "walkingEnd" /></p>

Start Time

End Time

Devil Running

	<p>What is your start and end time for your <a href="http://www.runnersworld.com/runners-stories/outrunning-the-demons" target="_blank">running workouts?</a></p>
	<p>Start Time<input type = "text" size = "6" name = "runningStart" />
	<p>End Time<input type = "text" size = "6" name = "runningEnd" /></p>

Start Time

End Time

<img src="deviltennis.jpg" width="200" height="200" alt="Devil Tennis" />	
	
	<p>What is your start and end time for your <a href="http://www.jesus-is-savior.com/Evils%20in%20America/Apostasy/judges_17-3.htm" target="_blank">tennis workouts?</a></p>
	<p>Start Time<input type = "text" size = "6" name = "tennisStart" />
	<p>End Time<input type = "text" size = "6" name = "tennisEnd" /></p>
	<p>Start Time<input type = "text" size = "6" name = "tennisStart1" />
	<p>End Time<input type = "text" size = "6" name = "tennisEnd1" /></p>
	
	<p>
	<input type = "submit" value = "How well was that burn?" />
	</p>

</form>
[/php]

In your first piece of code you are mixing html and php. A start will be to move your php code out of the head element, close your php at the end of the variable definitions. Then open and close your php around the variables when you use them in the subsequent html.

I also think you should get a better grasp of HTML/CSS before you tackle PHP. You don’t have to become a guru and it won’t take too long to get a strong foundation.

For example, you can simply do the following

[php][/php]

Plus I would also you label tags inside a form as much as possible, better syntax that way in my opinion.

[code]


What is your first name? <input type=“text” size=“20” name=“firstName”

What is your last name?

[/code]

You aren’t closing your elements either.

Here’s some changes I made.
[php]

Calories Burned Calculator

Calories Burned Calculator

Use military time

<form action = "calories.php" method = "post" >
<p>What is your first name?
<input type = "text" size = "20" name = "firstName"/>
	
<p>What is your last name?
<input type = "text" size = "20" name = "lastName"/></p>
	
<img src="baphbike.jpg" width="200" height="200" alt="Baphomet Cycle"/>
	
<p>What is your start and end time for your <a href="http://www.active.com/cycling/articles/how-to-look-like-a-cyclist" target="_blank">cycling workouts?</a></p>
<p>Start Time1
<p>End Time<input type = "text" size = "6" name = "cyclingEnd" placeholder="End Time"/></p>
<p>Start Time<input type = "text" size = "6" name = placeholder="cyclingStart1"/>
<p>End Time<input type = "text" size = "6" name = placeholder="cyclingEnd1"/></p>
	
	
	<img src="bluedevil.jpg" width="200" height="200" alt="swimming devil" />
	
	<p>What is your start and end time for your <a href="http://www.huffingtonpost.com/wicked-good-travel-tips/do-you-swim-in-sludge-ame_b_662131.html" target="_blank">swimming workouts?</a></p>
	<p>Start Time<input type = "text" size = "6" name = placeholder="swimmingStart" />
	<p>End Time<input type = "text" size = "6" name = placeholder="swimmingEnd" /></p>
	<p>Start Time<input type = "text" size = "6" name = placeholder="swimmingStart1" />
	<p>End Time<input type = "text" size = "6" name = placeholder="swimmingEnd1" /></p>

Baphomet Walking

	<p>What is your start and end time for your <a href="http://www.kelly-annmaddox.com/2013/02/walking-left-hand-path.html" target="_blank">walking workouts?</a></p>
	<p>Start Time<input type = "text" size = "6" name = placeholder="walkingStart" />
	<p>End Time<input type = "text" size = "6" name = placeholder="walkingEnd" /></p>

Start Time

End Time

Devil Running

	<p>What is your start and end time for your <a href="http://www.runnersworld.com/runners-stories/outrunning-the-demons" target="_blank">running workouts?</a></p>
	<p>Start Time<input type = "text" size = "6" name = placeholder="runningStart" />
	<p>End Time<input type = "text" size = "6" name = placeholder="runningEnd" /></p>

Start Time

End Time

<img src="deviltennis.jpg" width="200" height="200" alt="Devil Tennis" />	
	
	<p>What is your start and end time for your <a href="http://www.jesus-is-savior.com/Evils%20in%20America/Apostasy/judges_17-3.htm" target="_blank">tennis workouts?</a></p>
	<p>Start Time<input type = "text" size = "6" name = placeholder="tennisStart" />
	<p>End Time<input type = "text" size = "6" name = placeholder="tennisEnd" /></p>
	<p>Start Time<input type = "text" size = "6" name = placeholder="tennisStart1" />
	<p>End Time<input type = "text" size = "6" name = placeholder="tennisEnd1" /></p>
	
	<p>
	<input type = "submit" value = "How well was that burn?" />
	</p>

</form>
[/php] Is it closed correctly now and are there anymore suggestions?

Not sure if I separated it all correctly. Also Strider64 any suggestions to help me learn html/css?

I appreciate all the input.
[php]

Calories Burned Calculator
$cyclingStart = $_POST['cyclingStart'];
$cyclingEnd = $_POST['cyclingEnd'];
$swimmingStart = $_POST['swimmingStart'];
$swimmingEnd = $_POST['swimmingEnd'];
$walkingStart = $_POST['walkingStart'];
$walkingEnd = $_POST['walkingEnd'];
$runningStart = $_POST['runningStart'];
$runningEnd = $_POST['runningEnd'];
$tennisStart = $_POST['tennisStart'];
$tennisEnd = $_POST['tennisEnd'];
<?php
$totalCycling = ($cyclingStart / $cyclingEnd) * 650 = $totalCalories;
$totalSwimming = ($swimmingStart / $swimmingEnd) * 500 = $totalCalories;
$totalwalking = ($walkingStart / $walkingEnd) * 280 = $totalcalories;
$totalRunning = ($runningStart / $runningEnd) * 700 = $totalCalories;
$totalTennis = ($tennisStart / $tennisEnd) * 290 = $totalCalories;
?>
<link rel="stylesheet" type="text/css" href="sample.css" /></head>
print (" <h1>$lastName, $firstName </h1>");, you burned $totalCalories for $totalCycling minutes,

<p><a href = "calories.html">Calculate another day?</a></p>
[/php]

This kind of basics?

http://www.w3schools.com/html/html_css.asp

https://www.codecademy.com/learn/learn-html-css

…and then, perhaps this will be your next headache:
[php]$totalCycling = ($cyclingStart / $cyclingEnd) * 650 = $totalCalories;[/php]

i would do:
[php]$totalCycling = $cyclingStart / $cyclingEnd;[/php]
[php]$totalCalories = 650 * $totalCycling;[/php]

The time spent doing some activity, is it in hours or minutes? Curious as i do some running and for me it works out about 580 calories in about 35 minutes according to my Beurer watch with heart rate monitor.
Getting that formula wrong - one could burn a lot more calories for no extra effort ;D

Sponsor our Newsletter | Privacy Policy | Terms of Service