Accessing repetative variables from a form
Posted: Fri Jan 10, 2003 11:34 am
Hi,
I have a form in which i collect consecutive email and passwords
i.e. email1 pass1 email2 pass2
which i would then insert into a database
so far i have
$x=1;
while($x<=count($_POST)){
if(array_key_exists("Email".$x,$_POST)){
$Email = 'Email'.$x;
$Pass = array_push($_POST,$_POST['Password'.$x]);
$account[$Email]=array_push($Pass);
$x++;
}
}
while(list($k,$val)=each($account)){
echo "Email: ".$k." Password: ".$val."<br>";
// Note using this to test how the calues would come out
}
exit;
}
but im getting a timeout
im trying to figure out a simpler way but dont quite have the nail on the head
any suggestions?
Was there a way in the form i could have an array of the values already defined?
thus email1 email2 pass1 pass2 would be Email[] array Pass[] array
I have a form in which i collect consecutive email and passwords
i.e. email1 pass1 email2 pass2
which i would then insert into a database
so far i have
$x=1;
while($x<=count($_POST)){
if(array_key_exists("Email".$x,$_POST)){
$Email = 'Email'.$x;
$Pass = array_push($_POST,$_POST['Password'.$x]);
$account[$Email]=array_push($Pass);
$x++;
}
}
while(list($k,$val)=each($account)){
echo "Email: ".$k." Password: ".$val."<br>";
// Note using this to test how the calues would come out
}
exit;
}
but im getting a timeout
im trying to figure out a simpler way but dont quite have the nail on the head
any suggestions?
Was there a way in the form i could have an array of the values already defined?
thus email1 email2 pass1 pass2 would be Email[] array Pass[] array