I need to assign a value to my checkboxes so that not only they have a name, but a value. How would I do this? (on the next page I want to add up the price of the 3 games they might have selected).
$firstName = $_GET["first"];
$lastName = $_GET["last"];
$cityName = $_GET["city"];
$streetName = $_GET["street"];
$stateName = $_GET["state"];
$zipName = $_GET["zip"];
$gamesChecked = $_GET['games'];
if( isset( $_GET['games'] ) && strlen($streetName)>1 && strlen($firstName)>1 && strlen($lastName)>1 && strlen($cityName)>1 && strlen($zipName)==5) {
print "Thank you $firstName $lastName of <br/> $streetName $cityName, $stateName $zipName";
foreach ($gamesChecked as $games){
print "<br/>$games";
}
}
else if(strlen($streetName)<=1) {
print "Enter a valid street.";
Echo "<br/><a href=http://ift.tt/1M9esMC;";
}
else if(strlen($cityName)<=1) {
print "Enter a valid city.";
Echo "<br/><a href=http://ift.tt/1M9esMC;";
}
else if(strlen($firstName)<=1) {
print "Enter a valid name.";
Echo "<br/><a href=http://ift.tt/1M9esMC;";
}
else if(strlen($lastName)<=1) {
print "Enter a valid last name.";
Echo "<br/><a href=http://ift.tt/1M9esMC;";
}
else if(strlen($zipName)<5 || strlen($zipName)>5) {
print "Enter a correct Zip Code.";
Echo "<br/><a href=http://ift.tt/1M9esMC;";
}
else {
print "Select a Video Game.";
Echo "<br/><a href=http://ift.tt/1M9esMC;";
}
?>
That is the PHP here is the HTML of the checkboxes
<p>
<img src="SotC.jpg" alt="Shadow of the Colossus" /><input type="checkbox" name="games[]" value="Shadow of the Colossus"/>
Shadow of the Colossus - $20 <br/>
<img src="GoW.jpg" alt="God of War" /><input type="checkbox" name="games[]" value="God of War" />
God of War - $15 <br/>
<img src="HL.jpg" alt="Half-life" /><input type="checkbox" name="games[]" value="Half-Life" />
Half-Life - $10 <br/>
</p>
Aucun commentaire:
Enregistrer un commentaire