Ik heb een tell a friend pagina gemaakt.
In deze pagina kunnen naar 5 adressen mails worden verstuurd. Onderstaand script handeld dit af.
Nu wil ik dat de gegevens okk worden opgeslagen in mijn db maar ik kom er niet uit hoe ik die gegevens weer uit die lus kan halen.
Eerst het formulier
<? error_reporting (E_ALL);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Zegt het voort.</title>
<style type="text/css">
<!--
.style2 {color: #333333}
body,td,th {
color: #333333;
}
a:link {
color: #333333;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #333333;
}
a:hover {
text-decoration: underline;
color: #0000FF;
}
a:active {
text-decoration: none;
}
.style3 {
color: #333333;
font-weight: bold;
font-size: x-large;
}
-->
</style>
</head>
<body>
<table width="100%" height="0" >
<tr>
<td bgcolor="#999999"><table width="80%" height="0" align="center" >
<tr>
<td valign="top"><div align="center">
</div>
<table width="100%" height="300" bgcolor="#CCCCCC" >
<tr>
<td valign="top"><div align="center"> <p class="style3 style2">Vertel het anderen.<br>
</p>
<tr>
<body><form name="frm" method="post" action="sentaf1.php">
<table width="0%" align="center" >
<tr align="left">
<td width="113" scope="row">Uw eigen naam:</td>
<td width="594"><input type="text" name="sender" id="sender" size="30" /></td>
</tr>
<tr align="left">
<td width="113" scope="row">Uw eigen e-mail: </td>
<td width="594"><input type="text" name="sendermail" id="sendermail2" size="30" /></td>
</tr>
<tr align="left">
<td colspan="2" scope="row"><div align="left">Vul hieronder de emailadressen in van degene die u deze mail wilt sturen. </div></td>
</tr>
<tr align="left">
<td width="113" scope="row"> e-mail 1:</td>
<td width="594"><input type="text" name="mail_[]" id="mail1" size="30" /></td>
</tr>
<tr align="left">
<td width="113" scope="row">e-mail 2:</td>
<td width="594"><input type="text" name="mail_[]" id="mail2" size="30" /></td>
</tr>
<tr align="left">
<td width="113" scope="row">e-mail 3: </td>
<td width="594"><input type="text" name="mail_[]" id="mail3" size="30" /></td>
</tr>
<tr align="left">
<td width="113" scope="row">e-mail 4: </td>
<td width="594"><input type="text" name="mail_[]" id="mail4" size="30" /></td>
</tr>
<tr align="left">
<td width="113" scope="row">e-mail 5: </td>
<td width="594"> <input type="text" name="mail_[]" id="mail5" size="30" /> </td>
</tr>
<tr>
<td colspan="2" align="right" valign="top" scope="row"><div align="left">Hieronder vindt u een kant en klaar bericht, u kunt dit natuurlijk zelf aanpassen. </div></td>
</tr>
<tr>
<th colspan="2" align="right" valign="top" scope="row"><div align="left">Bericht:
</div></th>
</tr>
<tr>
<th colspan="2" align="right" valign="top" scope="row"><div align="center">
<textarea name="comment" id="textarea" cols="95" rows="24">Hallo,
hier komt het bericht</textarea>
<br>
</div></th>
</tr>
</table>
<div align="center">
<input type="submit" onclick="validate(), $registreer " value=" Verstuur deze email " />
</div>
</form>
<div align="center"></div>
</body>
</tr></table><br>
</div></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
<style type="text/css">
<!--
body,td,th {
color: #333333;
}
a:link {
color: #333333;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #333333;
}
a:hover {
text-decoration: underline;
color: #0000FF;
}
a:active {
text-decoration: none;
}
-->
</style>
<div align="center"></div>
<div align="center"></div>
</body>
</html>
en de verwerkingspagina
<?php
$i = 0;
$j = 0;
$total = 0;
$sender = $_POST['sender'];
$sendera=str_replace(" ","_",$sender);
$sendera= strtoupper($sendera);
$senderb=($sendera . " ". "oke");
$sendermail = $_POST['sendermail'];
$comment = $_POST['comment'];
for($j=0; $j<5; $j++) {
if(!empty ($_POST['mail_'][$j]))
$total++;
}
if(empty ($_POST['sender']))
header("Location: tfnosender.php");
elseif(empty ($_POST['sendermail']))
header("Location: tfnosendermail.php");
elseif($total == 0)
header("Location: tfnomail.php");
elseif(empty ($_POST['comment']))
header("Location: tfnocomment.php");
else {
for($i=0; $i<5; $i++) {
if(!empty ($_POST['mail_'][$i]))
mail($_POST['mail_'][$i], "Niks voor jullie? Afz. ".$sender, $comment, "From: ".$senderb);
}
if($total > 0 && $total <= 2)
header("Location: tfthanks.php");
if($total >= 3 && $total <= 5)
header("Location: tfthanks2.php");
}
error_reporting (E_ALL);
?>
399 views