I have the following code in my file:
<table width="100%" class="friends">
<tr>
<th width="50%">Friends Name</th>
<th>Friends Email</th>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
<tr>
<td><input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John & Jane Doe" style="width:80%;" /></td>
<td><input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /></td>
</tr>
And the following as my PHP Code:
if(!empty($_POST['friendname']) && !empty($_POST['friendemail']) && is_array($_POST['friendname']) && is_array($_POST['friendemail']) && count($_POST['friendname']) === count($_POST['friendemail'])) {
$err[] = "Please enter in your friend's details.";
}
$name_array = $_POST['friendname'];
$email_array = $_POST['friendemail'];
for ($i = 0; $i < count($name_array); $i++) {
$name = $name_array[$i];
$email = $name_array[$i];
}
However my code isn't echoing anything.
I got the code for the above from insert multiple fields using foreach loop
I have other fields inside my form and they work fine, but for some reason these don't. Does anyone know of a way to do what I'm looking for based on the code above? :)