Need help in checkbox

the mail() function

Moderators: egami, macek, gesf

Post Reply
User avatar
bigjoe11a
New php-forum User
New php-forum User
Posts: 137
Joined: Wed Aug 31, 2011 3:55 am
Location: USA
Contact:

Tue Sep 27, 2011 1:21 pm

It looks like your trying to set them in a array() and I'm not sure about that
//the html file

Code: Select all

<form>
<label for="website">Country</label>
<input name="c1" type="checkbox" value="India" />India
<input name="c2" type="checkbox" value="Australia" />Australia
<input name="c3" type="checkbox" value="UK" />UK
</form>
//the php code.

Code: Select all

<?php

$choices = array();

// Your using post to get the values

if(isset($_POST['c1'])) {
$choices[0] = $_POST['c1'];
} else if (isset($_POST['c2'])) {
$choices[1] = $_POST['c2'];
} else if (isset($_POST['c2'])) {
$choices[2] = $_POST['c3'];
}

foreach (choice as choices) {
echo 'Your choices are ' . choice;
}
?>
Try that

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest