Sign in to follow this  

[web] php problem

Recommended Posts

Hi, I have a form that uses mutiple checkbox values which i am sending to an php file for validation and i can't recieve those values. <form method = "post" action = "calcul.php" name = "form" > <input type = "checkbox" name = "var[]"> unu
<input type = "checkbox" name = "var[]"> doi
<input type = "checkbox" name = "var[]"> trei
<input type = "checkbox" name = "var[]"> patru
<input type = "checkbox" name = "var[]"> cinci
<input type = "submit" name = "submit" value = "submit"> <?php $variable = $_POST['var']; if (is_array{$variable}) { // print me the values } ?> Please help me.

Share this post

Link to post
Share on other sites
That is because you didn't set a value. The correct way of using is:

<input type="checkbox" name="var[]" value="value 1" /> Value 1<br />
<input type="checkbox" name="var[]" value="value 2" /> Value 2<br />

Also be sure you're working with the correct PHP version because in PHP 5.1.3 there is a bug with this kind of posting.

In PHP 5.1.4 this bug is fixed.

Good luck

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this