• Welcome to ForumKorner!
    Join today and become a part of the community.

Need some pHp help.

Status
Not open for further replies.

Boogeyman

Active Member
Reputation
0
New to pHp programming. This assignment is for one of my college classes. I don't even know if the pHp that I started is correct.

Using XAMPP

Problem: I'm trying to create a webpage that defines a form that allows you to enter 4 test scores into it and then display the total of those 4 scores. 

Here is the code that I currently have: 


Code:
<?php
 // get the data from the form
 $test_score1 = filter_input(INPUT_POST, 'test_score1');
 $test_score2 = filter_input(INPUT_POST, 'test_score2');
 $test_score3 = filter_input(INPUT_POST, 'test_score3');
 $test_score4 = filter_input(INPUT_POST, 'test_score4');
 
 // calculate the 4 total test scores
 $total = $test_score1 + test_score2 + test_score3 + test_score4
?>
<!DOCTYPE html>
<html>
<head>

 <link rel="stylesheet" type="text/css" href="TestScore.css">

<title>Test Score Calculator</title>


<body>



 <center><form action="display_exam.php" method="post">
 <div id="data">
 <label>Test Score 1:</label>
 <input type="text" name="test_score1"><br>
 <label>Test Score 2:</label>
 <input type="text" name"test_score2"><br>
 <label>Test Score 3:</label>
 <input type="text" name"test_score3"><br>
 <label>Test Score 4:</label>
 <input type="text" name"test_score4"><br>
 </div>
 <div id="buttons">
 <label>&nbsp;</label>
 <input type="submit" value"Calculate Test Scores"><br>
 </div>
 </form></center>
 

Zenta

User is banned.
Reputation
0
Boogeyman said:
New to pHp programming. This assignment is for one of my college classes. I don't even know if the pHp that I started is correct.

Using XAMPP

Problem: I'm trying to create a webpage that defines a form that allows you to enter 4 test scores into it and then display the total of those 4 scores. 

Here is the code that I currently have: 


Code:
<?php
 // get the data from the form
 $test_score1 = filter_input(INPUT_POST, 'test_score1');
 $test_score2 = filter_input(INPUT_POST, 'test_score2');
 $test_score3 = filter_input(INPUT_POST, 'test_score3');
 $test_score4 = filter_input(INPUT_POST, 'test_score4');
 
 // calculate the 4 total test scores
 $total = $test_score1 + test_score2 + test_score3 + test_score4
?>
<!DOCTYPE html>
<html>
<head>

 <link rel="stylesheet" type="text/css" href="TestScore.css">

<title>Test Score Calculator</title>


<body>



 <center><form action="display_exam.php" method="post">
 <div id="data">
 <label>Test Score 1:</label>
 <input type="text" name="test_score1"><br>
 <label>Test Score 2:</label>
 <input type="text" name"test_score2"><br>
 <label>Test Score 3:</label>
 <input type="text" name"test_score3"><br>
 <label>Test Score 4:</label>
 <input type="text" name"test_score4"><br>
 </div>
 <div id="buttons">
 <label>&nbsp;</label>
 <input type="submit" value"Calculate Test Scores"><br>
 </div>
 </form></center>

Lol, I see where your errors are. PM me and I'll help you out. Send me the forum URL too.
 

PrintLn

Onyx user!
Reputation
0
Zenta said:
Lol, I see where your errors are. PM me and I'll help you out. Send me the forum URL too.

This sounds sketchy.

The reason it's not appearing is that once you calculated the $total, you never displayed it. Make sure all of the POST parameters are set beforehand.
 
Status
Not open for further replies.
Top