Jump to content

Check Box Validating..


thara

Recommended Posts

Hello..

 

I have Two HTML form and one is a Check boxes form that enable users to select their category. Then I need to display second form according to the categories they selected in first form. I use this code in first form to validate form submission..

 

if ( isset( $_POST['category']) && sizeof( $_POST['category']) <= 3) {

 

$category = $_POST['category'];

 

} else {

 

$errors[] = 'Please select atleast 1, not more than 3 categories';

}

 

If errors array is empty I did this..

 

if ( empty( $errors )) {  // If everything's OK

 

$_SESSION = $category;

 

$url = 'http://localhost/lanka_institute/tutorsignup/select_subjects.php? // Define the URL.

ob_end_clean(); // Delete the buffer.

header("Location: $url");

exit(); // Quit the script.

 

}

 

 

Can I know and is this correct? I display category list from mysql category table, it has category name and category id

 

this is my html part from first page

 

echo '<td width="50%"><input type="checkbox" name="category[]"  vlaue="' . $info['category_id'] . '" />  ' . $info['category_name'] . '</td>';

 

 

any help appreciated.

 

Thanks in advance..

 

Link to comment
Share on other sites

in my first form  I display category list where user to select category. check boxes i used to each category. so I need to check what are the categories that users selected and they should display in my second form. so please tell me how can do this..

 

Do you clear my problem?

 

thank you..

Link to comment
Share on other sites

Its still problem.. my first form is 'sign_up.php'  and second is select_subject.php'.  sign_up.php page has more categories and  users can select up to 3 more categories there. So. after selecting and user click the continue bottom, page want to go to second form page its select_subject.php page. In there, i want to display the categories which user selected from sign_up.php page and also its provide to select subjects according to the categories they have selected.

 

my problem is how can I check what are the categories user have selected and how they display in my second page.

 

category come to first page from my category table. It has category_id and category_name columns.

 

thanks for any help..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.