I've got a question.....I've made sort of a shop....now i want to mail the cart to a destination mail adress....Thats works, but it only mails the last product and not all. The products are in a table called winkelwagen and are shown on the order page with a repeat function.
Now I want the value levnr from the winkelwagen table mailed...its in the form like this:
<input type="hidden" name="produkt" value="<?php echo $row_winkelwagen['levnr']; ?>">
where the name will be mailed like $produkt
So I figured out that I need a foreach function or something like that to insert all the values and not 1. But i dont know where to put it or how to write it....anyone????well seeing as you are in a while loop or should be, you can make $produkt an array
<input type="hidden" name="produkt[]" value="<?php echo $row_winkelwagen['levnr']; ?>">
then you can mail the whole thing.mmm, I see how this could work, only what should I put between the [] ? Now its sends the word array.....wel when you send you need to step through that array. many way to do it al it all depends on how you are sending the email
$total = count($produkt);
$message = "start message here";
for ($i=0; $i<$total; $i++){
$message .= "produkt: ". $produkt[$i];
}
mail($to,$subject, $message,$headers);
that is teh easiest way, but remember if you have a lot of emails to send php may timeout on you. besy to use perl for mass emailersmmmm, seems logical, but i cant figure out how to put it in my mailing message ) So I'll put down its code:
$email_webmaster = "[email protected]";
if(getenv(HTTP_X_FORWARDED_FOR)) { $IPadres = getenv(HTTP_X_FORWARDED_FOR); }
elseif(getenv(HTTP_CLIENT_IP)) { $IPadres = getenv(HTTP_CLIENT_IP); }
else { $IPadres = $REMOTE_ADDR; }
$hostmask = gethostbyaddr($REMOTE_ADDR);
if ($submit) {
if($contactpersoon == "") {
$ok = "nee";
$error_contactpersoon = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($bedrijfsnaam == "") {
$ok = "nee";
$error_bedrijfsnaam = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($adres == "") {
$ok = "nee";
$error_adres = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($postcode == "") {
$ok = "nee";
$error_postcode = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($plaats == "") {
$ok = "nee";
$error_plaats = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($telefoonnummer == "") {
$ok = "nee";
$error_telefoonnummer = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if(!eregi("[A-Za-z0-9_-]+([.]{1}[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([.]{1}[A-Za-z0-9-]+)+", $email)) {
$ok = "nee";
$error_email = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($ok != "nee") {
$datum = date("d-m-Y");
$tijd = date("H:i");
$winkelwagen=@mail("$email_webmaster", "Contact: $bedrijfsnaam", "
======================================================================
Leveringsnummer: $produkt ----- Aantal: $aantal
======================================================================
Contactpersoon: $contactpersoon
======================================================================
Bedrijfsnaam: $bedrijfsnaam
======================================================================
Adres: $adres
======================================================================
Postcode: $postcode
======================================================================
Plaats: $plaats
======================================================================
Telefoonnummer: $telefoonnummer
======================================================================
Mobiel nummer: $mobiel
======================================================================
Faxnummer: $faxnummer
======================================================================
Email: $email
======================================================================
Note: $contactpersoon stuurde deze email op $datum om $tijd.
======================================================================", "From: $contactpersoon<$email>");
if($winkelwagen == "1"){
Now I want the value levnr from the winkelwagen table mailed...its in the form like this:
<input type="hidden" name="produkt" value="<?php echo $row_winkelwagen['levnr']; ?>">
where the name will be mailed like $produkt
So I figured out that I need a foreach function or something like that to insert all the values and not 1. But i dont know where to put it or how to write it....anyone????well seeing as you are in a while loop or should be, you can make $produkt an array
<input type="hidden" name="produkt[]" value="<?php echo $row_winkelwagen['levnr']; ?>">
then you can mail the whole thing.mmm, I see how this could work, only what should I put between the [] ? Now its sends the word array.....wel when you send you need to step through that array. many way to do it al it all depends on how you are sending the email
$total = count($produkt);
$message = "start message here";
for ($i=0; $i<$total; $i++){
$message .= "produkt: ". $produkt[$i];
}
mail($to,$subject, $message,$headers);
that is teh easiest way, but remember if you have a lot of emails to send php may timeout on you. besy to use perl for mass emailersmmmm, seems logical, but i cant figure out how to put it in my mailing message ) So I'll put down its code:
$email_webmaster = "[email protected]";
if(getenv(HTTP_X_FORWARDED_FOR)) { $IPadres = getenv(HTTP_X_FORWARDED_FOR); }
elseif(getenv(HTTP_CLIENT_IP)) { $IPadres = getenv(HTTP_CLIENT_IP); }
else { $IPadres = $REMOTE_ADDR; }
$hostmask = gethostbyaddr($REMOTE_ADDR);
if ($submit) {
if($contactpersoon == "") {
$ok = "nee";
$error_contactpersoon = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($bedrijfsnaam == "") {
$ok = "nee";
$error_bedrijfsnaam = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($adres == "") {
$ok = "nee";
$error_adres = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($postcode == "") {
$ok = "nee";
$error_postcode = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($plaats == "") {
$ok = "nee";
$error_plaats = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($telefoonnummer == "") {
$ok = "nee";
$error_telefoonnummer = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if(!eregi("[A-Za-z0-9_-]+([.]{1}[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([.]{1}[A-Za-z0-9-]+)+", $email)) {
$ok = "nee";
$error_email = "<font face=\"Microsoft Sans-Serif,Arial\" size=\"2\" color=\"FF0000\"><b>*</b></font>";
}
if($ok != "nee") {
$datum = date("d-m-Y");
$tijd = date("H:i");
$winkelwagen=@mail("$email_webmaster", "Contact: $bedrijfsnaam", "
======================================================================
Leveringsnummer: $produkt ----- Aantal: $aantal
======================================================================
Contactpersoon: $contactpersoon
======================================================================
Bedrijfsnaam: $bedrijfsnaam
======================================================================
Adres: $adres
======================================================================
Postcode: $postcode
======================================================================
Plaats: $plaats
======================================================================
Telefoonnummer: $telefoonnummer
======================================================================
Mobiel nummer: $mobiel
======================================================================
Faxnummer: $faxnummer
======================================================================
Email: $email
======================================================================
Note: $contactpersoon stuurde deze email op $datum om $tijd.
======================================================================", "From: $contactpersoon<$email>");
if($winkelwagen == "1"){