Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Using checkboxes to select adoptables (http://www.mysidiaadoptables.com/forum/showthread.php?t=4249)

Isura 08-25-2013 09:39 AM

Using checkboxes to select adoptables
 
Hello,

I'm working on a group function to sort pets in different groups for Ruinily. It works fine so far I only have one small problem:

Current it's only possible to move one creature to one group at once. Since this is unpractical if people have a lot of pets, I want to do the selection over 'checkboxes':

PHP Code:

<form method='post'
...
<
input type='checkbox' name='movecreature[]' value='{$adopt->aid}' />
...
</
form

Unfortunately, the mysidia script doesn't allowe the transmission of arrays over post or get. I think the reason is the secure function in the input class:

PHP Code:

private function secure($data){
if(
is_array($data) and SUBDIR != "AdminCP") die ("Hacking Attempt!");
...


(Or in Mys v.1.3.3:)

PHP Code:

private function secure($data){
if(
is_array($data)) die ("Hacking Attempt!");
...


Is there a way to formulate an exception for a certain post variable? Something like:

PHP Code:

if(is_array($data) and !is_array($_POST("movecreature"))) die ("Hacking Attempt!"); 

I'm really thankful for every idea to solve this problem :pleased:.
(Sorry for my bad english ^^)

IntoRain 08-25-2013 03:04 PM

I tried it out and "Hacking Attempt!" does appear when I try to use an array to store the values.

If there's no way to prevent it, you can always create a checkbox for each adoptables. Then do a cycle (after submitting) to verify which checkboxes were checked and had PetID values on them then push those values to an array and well, do your group thing.

Like:

PHP Code:

//for each pet, add a checkbox
$checkbox = new CheckBox("name""Postname{$index}"value)
{
$index}++ //doing this, for each pet you'll have Postname1, Postname2, Postname3 etc.. value can be pet ID?

//after submitting/post
for($index 0$index numPets$index++)
{
    if(
$mysidia->input->post("Postname{$index}") != NULL//value not null means ID was stored/checked
{
     
$petID $mysidia->input->post("Postname{$index}");
     
//do whatever
}



Isura 08-26-2013 04:55 AM

Thank you :happyc:

That really helps me.

Ruinily 08-26-2013 08:40 AM

I just wanted to say thankyou too! ^_^

IntoRain 08-26-2013 01:05 PM

Glad to help! ^^

FounderSim 01-24-2016 11:07 PM

Here's what I just did getting value of multiple checkboxes
view stuff:
Code:

$cells->add(new CheckBox("", "select[]", "{$id}"));
code
Code:

                $select = $mysidia->input->post("select");
               
                for($i = 0; $i < count($select); $i++)
                {
                        //$select[$i]; my selected checkbox
                       
                }



All times are GMT -5. The time now is 07:39 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.