lundi 4 mai 2015

PHP :IF/ ELSE statement

Before you write the php code for this exercise,create the pseudocode solution. You can get some of the names for the variables by reading the code for both files. Name this file: gameSetup.txt and submit it withthe rest of these files

You do not to change gameSetup.html which receives a game character's name, type, strength, intelligence and experience rating from the user. The gameSetup.php should receive these inputs and then test if the combined three ratings add up to more than 10. If they do the program should display an error message and a link back to gameSetup.html so that the user can try again (the output statement has been provided). Otherwise the program should process the user input as follows: Use a selection control structure to assign values for the character's health, and a second selection control structure to assign the number of pieces of gold that the character owns. The output statements have been provided. Use the following rules to create your selection structures:  All characters receive an initial health rating of 10. The health rating may be increased if any of the following apply:  Dwarves and Wizards add 10 their health score.  Humans add 5 to their health score if their experience is below 2  Elves add 5 to their health score if their intelligence is at least 3.  Dwarves and Wizards are always assigned 0 pieces of gold. Humans and elves are assigned 10 pieces of gold if their health rating is above 10, otherwise humans and elves are assigned 20 pieces of gold.

This is what i got:

$charName = $_POST['charName'];
$charType = $_POST['charType'];
$charExperience = $_POST['charExperience'];
$charStrength = $_POST['charStrength'];
$charIntelligence = $_POST['charIntelligence'];


if ($total > 10)
{
    print("<p>Your three rating combined cannot exceed 10 points</p>
           <p><a href = \"gameSetup.html\" >Try again</a></p>");
         $total = $charExperience + $charStrength + $charIntelligence; 

what do i do from here: please help

Aucun commentaire:

Enregistrer un commentaire