Welcome Guest, Not a member yet? Register   Sign In
Passing Array Data
#1

[eluser]ealonw[/eluser]
This doesnt work in CI... Its form data (input field and radio buttons) I was trying to turn each POST into an argument and do a foreach. But it deosnt work in CI.. Here is the code below.

$first_name=$_POST['First_Name'];
$arg['first_name']=$first_name;
$last_name=$_POST['Last_Name'];
$arg['last_name']=$last_name;
$email=$_POST['E_Mail'];
$arg['email']=$email;
$grad_year=$_POST['GradYear'];
$arg['grad_year']=$grad_year;

if ($_POST{'am0'}){ $amcount++; }
if ($_POST{'am1'}){ $amcount++; }
if ($_POST{'am2'}){ $amcount++; }
if ($_POST{'am3'}){ $amcount++; }
if ($_POST{'am4'}){ $amcount++; }
if ($_POST{'am5'}){ $amcount++; }
if ($_POST{'am6'}){ $amcount++; }
if ($_POST{'am7'}){ $amcount++; }
if ($_POST{'am8'}){ $amcount++; }
if ($_POST{'am9'}){ $amcount++; }

if ($_POST{'cf0'}){ $cfcount++; }
if ($_POST{'cf1'}){ $cfcount++; }
if ($_POST{'cf2'}){ $cfcount++; }
if ($_POST{'cf3'}){ $cfcount++; }
if ($_POST{'cf4'}){ $cfcount++; }
if ($_POST{'cf5'}){ $cfcount++; }
if ($_POST{'cf6'}){ $cfcount++; }
if ($_POST{'cf7'}){ $cfcount++; }
if ($_POST{'cf8'}){ $cfcount++; }
if ($_POST{'cf9'}){ $cfcount++; }

if ($_POST{'fd0'}){ $fdcount++; }
if ($_POST{'fd1'}){ $fdcount++; }
if ($_POST{'fd2'}){ $fdcount++; }
if ($_POST{'fd3'}){ $fdcount++; }
if ($_POST{'fd4'}){ $fdcount++; }
if ($_POST{'fd5'}){ $fdcount++; }
if ($_POST{'fd6'}){ $fdcount++; }
if ($_POST{'fd7'}){ $fdcount++; }
if ($_POST{'fd8'}){ $fdcount++; }
if ($_POST{'fd9'}){ $fdcount++; }

if ($_POST{'gd0'}){ $gdcount++; }
if ($_POST{'gd1'}){ $gdcount++; }
if ($_POST{'gd2'}){ $gdcount++; }
if ($_POST{'gd3'}){ $gdcount++; }
if ($_POST{'gd4'}){ $gdcount++; }
if ($_POST{'gd5'}){ $gdcount++; }
if ($_POST{'gd6'}){ $gdcount++; }
if ($_POST{'gd7'}){ $gdcount++; }
if ($_POST{'gd8'}){ $gdcount++; }
if ($_POST{'gd9'}){ $gdcount++; }

if ($_POST{'id0'}){ $idcount++; }
if ($_POST{'id1'}){ $idcount++; }
if ($_POST{'id2'}){ $idcount++; }
if ($_POST{'id3'}){ $idcount++; }
if ($_POST{'id4'}){ $idcount++; }
if ($_POST{'id5'}){ $idcount++; }
if ($_POST{'id6'}){ $idcount++; }
if ($_POST{'id7'}){ $idcount++; }
if ($_POST{'id8'}){ $idcount++; }
if ($_POST{'id9'}){ $idcount++; }

if ($_POST{'mm0'}){ $mmcount++; }
if ($_POST{'mm1'}){ $mmcount++; }
if ($_POST{'mm2'}){ $mmcount++; }
if ($_POST{'mm3'}){ $mmcount++; }
if ($_POST{'mm4'}){ $mmcount++; }
if ($_POST{'mm5'}){ $mmcount++; }
if ($_POST{'mm6'}){ $mmcount++; }
if ($_POST{'mm7'}){ $mmcount++; }
if ($_POST{'mm8'}){ $mmcount++; }
if ($_POST{'mm9'}){ $mmcount++; }

if ($_POST{'td0'}){ $tdcount++; }
if ($_POST{'td1'}){ $tdcount++; }
if ($_POST{'td2'}){ $tdcount++; }
if ($_POST{'td3'}){ $tdcount++; }
if ($_POST{'td4'}){ $tdcount++; }
if ($_POST{'td5'}){ $tdcount++; }
if ($_POST{'td6'}){ $tdcount++; }
if ($_POST{'td7'}){ $tdcount++; }
if ($_POST{'td8'}){ $tdcount++; }
if ($_POST{'td9'}){ $tdcount++; }

if ($_POST{'vc0'}){ $vccount++; }
if ($_POST{'vc1'}){ $vccount++; }
if ($_POST{'vc2'}){ $vccount++; }
if ($_POST{'vc3'}){ $vccount++; }
if ($_POST{'vc4'}){ $vccount++; }
if ($_POST{'vc5'}){ $vccount++; }
if ($_POST{'vc6'}){ $vccount++; }
if ($_POST{'vc7'}){ $vccount++; }
if ($_POST{'vc8'}){ $vccount++; }
if ($_POST{'vc9'}){ $vccount++; }

if ($_POST{'pd0'}){ $pdcount++; }
if ($_POST{'pd1'}){ $pdcount++; }
if ($_POST{'pd2'}){ $pdcount++; }
if ($_POST{'pd3'}){ $pdcount++; }
if ($_POST{'pd4'}){ $pdcount++; }
if ($_POST{'pd5'}){ $pdcount++; }
if ($_POST{'pd6'}){ $pdcount++; }
if ($_POST{'pd7'}){ $pdcount++; }
if ($_POST{'pd8'}){ $pdcount++; }
if ($_POST{'pd9'}){ $pdcount++; }



if ($amcount > $minresponses){$count++;}
$arg['amcount']=$amcount;
if ($cfcount > $minresponses){$count++;}
$arg['cfcount']=$cfcount;
if ($fdcount > $minresponses){$count++;}
$arg['fdcount']=$fdcount;
if ($gdcount > $minresponses){$count++;}
$arg['gdcount']=$gdcount;
if ($idcount > $minresponses){$count++;}
$arg['idcount']=$idcount;
if ($mmcount > $minresponses){$count++;}
$arg['mmcount']=$mmcount;
if ($tdcount > $minresponses){$count++;}
$arg['tdcount']=$tdcount;
if ($vccount > $minresponses){$count++;}
$arg['vccount']=$vccount;
if ($pdcount > $minresponses){$count++;}
$arg['pdcount']=$pdcount;



//echo $pdcount;

function writeToTxtFile($arg){
//print_r($arg);

$i=1;
foreach($arg as $key=>$value){

$str.=":: $key =".$value;

}
$i++;

$str.="\r\n";
file_put_contents('store.txt',$str,FILE_APPEND);
}

writeToTxtFile($arg);
#2

[eluser]Andreas Krohn[/eluser]
Have you tried the $this->input->post('post_parameter_name') instead of using $_POST? Or isn't the problem acctually getting the posted data?
#3

[eluser]ealonw[/eluser]
$fname = $this->input->post('fname'); Yes you are right.. The form writes to the filefor the input fields but the problem is formatting the radio buttons and how can I create an arg for each POST type.

Just an example of HTML
<input type="text" name="fname" size="30">
<input type="text" name="lname" size="30">
<input type="radio" name="gd1" value="yes"> yes   <input type="radio" name="gd1" value="no">




Theme © iAndrew 2016 - Forum software by © MyBB