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
Accessing repetative variables from a form
Moderator: General Moderators
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
Accessing repetative variables from a form
opps
that line should be
$account[$Email]=$Pass;
that line should be
$account[$Email]=$Pass;
try this one
Code: Select all
<html><body>
<p><table border="1">
<tr><th>email</th><th>password</th></tr>
<?php
if (isset($_POST['ep']))
{
foreach($_POST['ep'] as $entry)
echo '<tr><td>', $entry['email'], '</td><td>', $entry['pass'], '</td></tr>';
}
?></table></p>
<form method="POST">
email:<input type="text" name="ep[0][email]" /> password:<input type="text" name="ep[0][pass]" />
<br/>
email:<input type="text" name="ep[1][email]" /> password:<input type="text" name="ep[1][pass]" />
<br/>
email:<input type="text" name="ep[2][email]" /> password:<input type="text" name="ep[2][pass]" />
<br/>
<input type="submit"/>
</form>
</body></html>