Jump to content

Checkbox + PHP


adicrst

Recommended Posts

i want to use some checkboxes in a php script, but it's not working

<form action='' method='post'>language: <input type="checkbox" name="language" value="romanian"> Romanian		<input type="checkbox" name="limba" value="english"> English		<input type="checkbox" name="limba" value="japanese"> Japanase		<input type="submit" name="submit" value="send">		</form><?phpif (isset($_POST['submit']))	{		echo "Languages: ".$_POST['language'];	}else	{		echo ' select langeuages';	}

the thing is that if i select more then one option, it only gives me one record and the last onehow do i make it to show me all the options ?

Link to comment
Share on other sites

put [] after the name, then php will have them in an array<input type="checkbox" name="language[]" value="Romanian" /><input type="checkbox" name="language[]" value="English" /><input type="checkbox" name="language[]" value="Japanese" />Selecting the first and second, will give in php:array( 'language' => array( 0 => 'Romanian', 1 => 'English' ))

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...