I'd like some help here if you can. I'll explain:
I've built a form in html (which you can see here: http://www.bastosviegas.com/bastos_pt/e ... r_serv.php) with a javascript to enable people to add row on a table.
Here's the javascript:
Code: Select all
<script type="text/javascript">
function addRowToTable()
{
var tbl = document.getElementById('tblAddress');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
// var iteration = lastRow + 1;
var row = tbl.insertRow(lastRow);
// cell 0
var cell0 = row.insertCell(0);
var el = document.createElement('input');
el.type = 'text';
el.NAME = 'cod[]';
el.id = 'cod[]';
el.size = 14;
cell0.appendChild(el);
//cell 1
var cell1 = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.NAME = 'descri[]';
el.id = 'descri[]';
el.size = 48;
cell1.appendChild(el);
//cell 2
var cell2 = row.insertCell(2);
var el = document.createElement('input');
el.type = 'text';
el.NAME = 'qty[]';
el.id = 'qty[]';
el.size = 14;
cell2.appendChild(el);
}
</script>This brings us to my problem, which i believe is in the php file which is being used by the form.
The purpose of this is to email the form. I can get it to work with simple input field IDs (unique), but it's not passing the array of values for my cod[] , descri[] , qty[]. I suppose this is a code flaw on my part (I'm not a programmer, although I like to develop this kind of stuff), so here's the code:
(i've taken out some parts that don't matter for this case)
Code: Select all
<?php
$to = "email@address.com";
$fax = $_POST['fax'];
$email = $_POST['email'];
$arrCod = explode("\n", $_POST["cod"]);
$arrDescri = explode("\n", $_POST["descri"]);
$arrQty = explode("\n", $_POST["qty"]);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "Site encomenda";
$EmailBody = " Fax: $fax\n
Email: $email\n
";
foreach ( $arrCod as $codigos ) {
$EmailBody .= " Codigo: $codigos\n";
}
foreach ( $arrDescri as $descricao ) {
$EmailBody .= " Descricao: $descricao\n";
}
foreach ( $arrQty as $quantidade ) {
$EmailBody .= " Quantidade: $quantidade\n";
}
// Validation stuff
// mail() function
exit;
?>Codigo: Array
Descricao: Array
Quantidade: Array
How can I get this to work?
Thank you very much!