/    Sign up×
Community /Pin to ProfileBookmark

what is the php code for me to view all the checked boxes…

hi! here is my php…. i need a code that can display the checked boxes.. what happens is that even if i check all boxes, the last checkbox value only will be displayed in the result page…

[B]here is the html code..[/B]
<td><input name=”interest” type=”checkbox” id=”interest” value=”Cuisines”>
Cuisines <br>
<input name=”interest” type=”checkbox” id=”interest” value=”Foods”>
Foods <br>
<input name=”interest” type=”checkbox” id=”interest” value=”Recipes”>
Recipes<br>
<input name=”interest” type=”checkbox” id=”interest” value=”kitchen”>
Kitchen

[B]here is my php:[/B]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
http://www.w3.org/TR/html4/loose.dtd“>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title>Japonji Subscription</title>
<link href=”o.css” rel=”stylesheet” type=”text/css”>
<style type=”text/css”>
<!–
.style12 {
font-family: Arial, Helvetica, sans-serif;
font-size: 36px;
color: #993300;
}
–>
</style>
</head>

<body>
<form name=”form1″ method=”post” action=””>
<table width=”770″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″>
<tr>
<td height=”210″ colspan=”3″><img src=”images/japonji_01.gif” width=”770″ height=”210″ align=”texttop”></td>
</tr>
<tr>
<td width=”89″ height=”490″ rowspan=”2″ valign=”bottom” background=”images/japonji_02.gif” class=”unnamed1″><img src=”images/japonji_02.gif” width=”89″ height=”490″></td>
<td width=”612″ height=”412″ align=”center” valign=”top” background=”images/japonji_03.gif”><div align=”left”><span class=”style12″>Subscription Sent! <br>
<br>
<?
$name= $_POST[“name”];
$email= $_
POST[“email”];
$gender= $_POST[“gender”];
$status= $_
POST[“status”];
$age= $_POST[“age”];
$address= $_
POST[“address”];
$city= $_POST[“city”];
$username= $_
POST[“username”];
$password= $_POST[“password”];
$subscription= $_
POST[“subscription”];
$interest= $_POST[“interest”];

if ($gender==”female”)
{
print (“<font color=red face=arial size=5> Good Day, Madamme!<br>”);
print (“<font color=black face=arial size=3> The following information are listed below for your subscription review.<br><br>”);
print (“<font color=black face=arial size=3>Name: $name<br>”);
print (“<font color=black face=arial size=3>Age: $age<br>”);
print (“<font color=black face=arial size=3>Gender: $gender<br>”);
print (“<font color=black face=arial size=3>Status: $status<br>”);
print (“<font color=black face=arial size=3> Address: $address<br>”);
print (“<font color=black face=arial size=3> City: $city<br><br>”);
print (“<font color=black face=arial size=3> Email: $email<br>”);
print (“<font color=black face=arial size=3> Username: $username<br>”);
print (“<font color=black face=arial size=3> Password: $password<br><br>”);
print (“<font color=black face=arial size=3> Subscription: $subscription<br>”);
print (“<font color=black face=arial size=3> Interest: $interest<br>”);
}else{
print (“<font color=blue face=arial size=5> Good Day, Sir!<br>”);
print (“<font color=black face=arial size=3> The following information are listed below for your subscription review.<br><br>”);
print (“<font color=black face=arial size=3>Name: $name<br>”);
print (“<font color=black face=arial size=3>Age: $age<br>”);
print (“<font color=black face=arial size=3>Gender: $gender<br>”);
print (“<font color=black face=arial size=3>Status: $status<br>”);
print (“<font color=black face=arial size=3>Address: $address<br>”);
print (“<font color=black face=arial size=3>City: $city<br><br>”);
print (“<font color=black face=arial size=3>Email: $email<br>”);
print (“<font color=black face=arial size=3>Username: $username<br>”);
print (“<font color=black face=arial size=3>Password: $password<br><br>”);
print (“<font color=black face=arial size=3>Subscription: $subscription<br>”);
print (“<font color=black face=arial size=3> Interest: $interest<br>”);
$to=”[email protected]“;
$subject=”email message”;
$message=”Form Details: $name<br>,$age<br>,$gender<br>,$address<br>,$city<br>,$email<br>,$username<br>,$password<br>,$subscription<br>,$interest”;
$from=”FROM: $email”;
mail($to,$subject,$message,$from);
}
?>
</span></div></td>

<td width=”69″ height=”490″ rowspan=”2″ valign=”bottom” background=”images/japonji_04.gif” class=”unnamed1″><img src=”images/japonji_04.gif” width=”69″ height=”490″></td>
</tr>
<tr>
<td width=”612″ height=”78″ valign=”top” background=”images/japonji_05.jpg” class=”unnamed1″>&nbsp;</td>
</tr>

</table>
</form>

</body>
</html>

…hope i can get some code from u.. tnx

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@DariaAug 09.2006 — I am not sure - please, do not take me reply for an answer since I am a novice and might be wrong - but I think you should dig in the direction of not having same id for the checkboxes... - if that is not it, at least you will find an answer in related reading.
Copy linkTweet thisAlerts:
@PineSolPirateAug 09.2006 — Daria is right, you need unique names for each checkbox.

Then, if the box is checked, the $_POST value of that name will be whatever value you have in the checkbox value attribute.
Copy linkTweet thisAlerts:
@PineSolPirateAug 09.2006 — Example:
[code=html]<input name="cuisines" type="checkbox" id="cuisines" value="Y">
Cuisines <br>
<input name="foods" type="checkbox" id="foods" value="Y">
Foods <br>[/code]

[code=php]print "Interested in cuisines? ".$_POST['cuisines']."<br/>";[/code]
If cuisines is checked then it prints
Interested in cuisines? Y
Otherwise it prints
Interested in cuisines?
So you can use checkboxes as true/false flags in your code, like
[code=php]if("Y" == $_POST['cuisines']) {
print "They are interested in cuisines!";
}[/code]
Copy linkTweet thisAlerts:
@chowiieauthorAug 10.2006 — tnx for everything.. i have submitted my project?
×

Success!

Help @chowiie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...