ahojte, chlapi potrebujem poradiť neviem z akého dôvodu mi nefunguje foreach v skripte, presnejšie $data[$key] je to stále prázdne keď dám vypísať napríklad $data['email'] tak mi nič nevypíše, ale keď dám vypísať $_POST['email'] tak už ten email z formulára vypíše...
Kód:
<?php
function filter($data) {
$data = trim(htmlentities(strip_tags($data)));
if (get_magic_quotes_gpc())
$data = stripslashes($data);
$data = mysql_real_escape_string($data);
return $data;
}
if(isset($_POST['doRegister']) && $_POST['doRegister'] == 'Register')
{
foreach($_POST as $key => $value) {
$data[$key] = filter($value);
}
}
?>
<form action='register.php' method='post' name='logForm' id='regForm'>
<table>
<tr>
<th>First name:</th>
<td><input type='text' name='firstname' id='firstname' value=''></td>
</tr>
<tr>
<th>Last name:</th>
<td><input type='text' name='lastname' id='lastname' value=''></td>
</tr>
<tr>
<th>E-mail:</th>
<td><input type='text' name='email' id='email' value=''></td>
</tr>
<tr>
<th>Password:</th>
<td><input type='password' name='password' id='password' value=''></td>
</tr>
<tr>
<th>Retype password:</th>
<td><input type='password' name='password2' id='password2' value=''></td>
</tr>
<tr>
<th></th>
<td align='center'><input name="doRegister" type="submit" id="doRegister" value="Register"></td>
</tr>
</table>
</form>