Sorry i am a bit of a newbie.
I have a form with some inputs which are arrays and some which are not
<input type="text" name="name" value="name1111" />
<input type="text" name="email" value="email1111" />
<input type="text" name="model[]" value="model1111" />
<input type="text" name="serial[]" value="serial1111" />
<input type="text" name="read[]" value="read1111" />
<input type="text" name="model[]" value="model2222" />
<input type="text" name="serial[]" value="seria2222" />
<input type="text" name="read[]" value="read2222" />
<input type="text" name="model[]" value="model3333" />
<input type="text" name="serial[]" value="serial3333" />
<input type="text" name="read[]" value="read3333" />
<!-- model4444 etc.. dynamically added with jquery as needed -->
when i post them to read.php and use foreach the output repeats the name and email instead of posting once. i am not sure what to do to make it work.
this is what i am trying
$name = $_POST['name'];
$email = $_POST['email'];
$model = $_POST['model'];
$serial = $_POST['serial'];
$read = $_POST['read'];
$a = "Meter Readings From Customer - $name with contact $email";
foreach ( $model as $key => $n ) {
$b = "Model - " . $n . "with Serial No. " . $serial[$key] . " has a Reading of - " . $read[$key] . ". End of Reading\n";
echo $a . $b;
}
i want it to come out like this
Meter Readings From Customer - name1111 with contact email1111
Model - model1111 with Serial No. serial1111 has a Reading of read1111. End of Reading
Model - model2222 with Serial No. serial2222 has a Reading of read2222. End of Reading
Model - model3333 with Serial No. serial3333 has a Reading of read3333. End of Reading
with the end goal being able to get it into $msg then mail it and return a success message with this
if(mail($address, $e_subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n")) {
echo "<fieldset>";
echo "<div id='success_page'>";
echo "<h1>Email Sent Successfully.</h1>";
echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>";
echo "</div>";
echo "</fieldset>";
} else {
echo 'ERROR!';
}
}
I would be so grateful if someone could help me with this