I'm working on a form, I loaded the array from a txt file. That works perfect.
I got like 30 lines now. But what I now want is a image before each line.
But the image have to be the image of the product from the line..
The image can be the same name as the array line.
Is that posible? and how?
So:
- [ array ]
image2 [product2]
image3 [product3]
Here the code:
Code: Select all
<?php
$aProducten = file("../content/novaa_content.txt");
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$aProducten = stripslashes_deep($aProducten);
$aBesteld = array();
$wanneer_dag = $_POST['wanneer_dag'];
$wanneer_maand = $_POST['wanneer_maand'];
$opmerking = $_POST['opmerkingen'];
$mail = $_POST['adres'];
$naam = $_POST['naam'];
$sex = $_POST['sex'];
$aan = "mail@tentyproductions.nl";
$onderwerp = "Bestelling Novotel Amsterdam Airport";
$aan2 = "".$mail."";
$onderwerp2 = "Uw Bestelling";
$pattern = "/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/";
echo '<form method="post" action="'.$_SERVER['REQUEST_URI'].'">';
echo '<table border="0" class="bestel" cellspacing="0" width="470px">';
foreach($aProducten as $iKey => $sValue) {
echo '<tr><td class="randje"><input size="20" type="text" name="aantal_'.$iKey.'" id="aantal" class="textInput" /> <font size="1" color="#e2007a">ex.</font></td><td class="randje"> <td><td class="randje">'.$sValue.'</td></tr>';
}
echo '</table><p><div id="lijn"></div></p><p><table class="bestel" border="0">';
echo '<tr><td align="right"><font color="#e2007a">*</font> Naam: <input type="text" name="naam" id="naamblok" class="textInput" /></td>';
echo '<td align="right"><font color="#e2007a">*</font> <input type="radio" name="sex" value="Dhr. " />Dhr. <input type="radio" name="sex" value="Mvr. " />Mvr.</td></tr>';
echo '<tr><td align="right"><font color="#e2007a">*</font> Email: <input type="text" name="adres" id="mail" class="textInput" /></td></tr>';
echo '<tr><td align="right"><font color="#e2007a">*</font> Dag: <select name="wanneer_dag" id="wanneer" />
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select> <font color="#e2007a">*</font> Maand: <select name="wanneer_maand" id="wanneer" />
<option>januari</option>
<option>februari</option>
<option>maart</option>
<option>april</option>
<option>mei</option>
<option>juni</option>
<option>juli</option>
<option>augustus</option>
<option>september</option>
<option>oktober</option>
<option>november</option>
<option>december</option>
</select><td> Gewenste leverdatum</td><td>';
echo '<tr><p><td>Opmerkingen:</td></tr>';
echo '<tr><td><textarea name="opmerkingen" cols="40" rows="7"></textarea></td></p></tr>';
echo '<tr><td height="20px"><div id="lijn"></div><tr></td><td colspan="2"><input type="submit" value="Bestel" /> <input type="reset" value="Opnieuw" /></td></tr>';
echo '</table></p></form>';
if($_SERVER['REQUEST_METHOD'] == "POST") {
for($i=0;$i<=count($aProducten);$i++) {
if(isset($_POST['aantal_'.$i]) && is_numeric($_POST['aantal_'.$i])) {
$aBesteld[] = array($i, $_POST['aantal_'.$i]);
}
}
if (empty($_POST['aantal_'.$iKey.'']) || '') {
echo '<font color="#e2007a" size="3">U heeft geen aantal ingevuld.</font><br />';
}
if (empty($_POST['naam']) || '') {
echo '<font color="#e2007a" size="3">U heeft geen naam ingevuld.</font><br />';
}
if ( !isset($_POST['adres']) or !preg_match( '~^[a-z0-9][a-z0-9_.\-]*@([a-z0-9]+\.)*[a-z0-9][a-z0-9\-]+\.([a-z]{2,6})$~i', $_POST['adres'] ) ) {
echo '<font color="#e2007a" size="3">U heeft geen email ingevuld.</font><br />';
}
else{
$aan = "mail@tentyproductions.nl";
$onderwerp = "Bestelling Novotel Amsterdam Airport";
$bericht = "Beste Stephan,\n\n Hier onder staat de bestelling van Amsterdam Airport.\n\n";
foreach($aBesteld as $aProduct) {
list($iProduct, $iAantal) = $aProduct;
$bericht .= "• ".$iAantal." ex - ".$aProducten[$iProduct]." ";
}
$bericht .= "\n Aanleverdatum: ".$wanneer_dag." ".$wanneer_maand."\n\n Opmerking:\n ".$opmerking." \n\n Met vriendelijke groet,\n ".$sex." ".$naam."";
$aan2 = "".$mail."";
$onderwer2p = "Uw Bestelling";
$bericht2 = "Beste ".$sex." ".$naam.",\n\n Hier onder staat uw bestelling.\n\n";
foreach($aBesteld as $aProduct) {
list($iProduct, $iAantal) = $aProduct;
$bericht2 .= "• ".$iAantal." ex - ".$aProducten[$iProduct]." ";
}
$bericht2 .= "\n Aanleverdatum: ".$wanneer_dag." ".$wanneer_maand."\n\n Opmerking:\n ".$opmerking." \n\n Met vriendelijke groet,\n het Tenty team";
mail($aan, $onderwerp, $bericht, "FROM: $mail");
mail($aan2, $onderwerp2, $bericht2, "FROM: mail@tentyproductions.nl");
echo "<script type='text/javascript'>window.location='../dank.php';</script>";
}
}
?>THANKS