Sunday 7 January 2018

How To Get Multiple Checkbox Values In PHP?

Step 1:
Start the XAMPP server
Click on the "Start" button next to "Apache" to start your Apache Web server and also start "MySQL"

Step 2:
Create Drop.html

<!doctype html>
<html lang="en:US">
<head>
<meta charset="UTF-8">
<title>Get CheckBox Value</title>
</head>

<body>

<form method="post" action="dop.php">

Hobbies:</br>
<input type="checkbox" name="check_list[]" value="Dancing">Dancing </br>
<input type="checkbox" name="check_list[]"value="Singing">Singing</br>
<input type="checkbox" name="check_list[]" value="Netsurfing">Netsurfing </br>

<input type="submit" name="submitbtn" value="Click"/>

</form>

</body>

</html>

Step 3: 

Create dop.php

  <?php
    if(isset($_POST['submitbtn']))
    {
            if(!empty($_POST['check_list']))
            {
$checked = count($_POST['check_list']);

echo "You have selected ".$checked." items: <br/>";

foreach($_POST['check_list'] as $select)
{
echo "<p>".$select ."</p>";
}

}

else
{
echo "<i>Please Select at least One Option.</i>";
}

}

?>
Step 4 :

Save both the file(Drop.html,dop.php) in htdocs under  xampp  server in c:drive.

Step  5:

Open the browser (chrome) and type it
localhost/ Drop.html

Hobbies:
Dancing
Singing
Netsurfing


After clicking on button you can get the following output

You have selected 3 items:
Dancing
Singing
Netsurfing


1 comment:

  1. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our
    Best Dot Net Training Institute in Chennai
    Best Software Testing Training Institute in Chennai With Placement
    Java Certification in Chennai
    PHP Training Institute in Chennai

    ReplyDelete

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...