Tim Hovius
Gebruiker
- Lid geworden
- 25 jan 2008
- Berichten
- 788
Hallo, ik probeer een email formulier te maken, maar als de gebruiker bijv. geen naam invoert, moet dit op DEZELFDE pagina verschijnen met een melding.
Ik krijg dit niet voor elkaar.
Op de plaats <?php echo "$foutnaam <BR /> (en de andere) moet het bericht komen
Wie heeft een oplossing?
Nu echo ik het gewoon, maar dan maakt PHP een nieuwe pagina aan
Ik krijg dit niet voor elkaar.
Op de plaats <?php echo "$foutnaam <BR /> (en de andere) moet het bericht komen

Wie heeft een oplossing?
Nu echo ik het gewoon, maar dan maakt PHP een nieuwe pagina aan

PHP:
<html>
<head>
<title>Contact</title>
<link rel="stylesheet" type="text/css" href="style.css">
<style type="text/css">
</style>
</head>
<body>
<?php
if (!empty($_POST)){
$naam = $_POST['naam'];
$email = $_POST['email'];
$onderwerp = $_POST['onderwerp'];
$bericht = $_POST['bericht'];
$headers = "Van: ".$naam." <".$email.">\r\n";
if(!$naam) {
echo "Vul uw naam in!";
}
elseif(!$email) {
echo "Vul uw emailadres in!";
}
elseif(!$onderwerp) {
echo "Vul uw onderwerp in!";
}
elseif(!$bericht) {
echo "Vul uw bericht in!";
}
else {
if (!mail("hier stond mijn emailadres", $onderwerp, $bericht, $headers)){
echo "Er is een fout opgetreden bij het verzenden van e-mail";
}
else {
// succesvol verzonden, doorsturen naar bedankt-pagina
echo "Uw bericht is verzonden";
}
}
}
else {
?> <center>
<table class="inhoud">
<tr>
<td class="off" onclick="location.href='index.htm'" onmouseover="this.className='on'" onmouseout="this.className='off'">
Homepagina</td>
<td class="off" onclick="location.href='opdrachten.htm'" onmouseover="this.className='on'" onmouseout="this.className='off'">
Opdrachten boekje</td>
<td class="off" onclick="location.href='contact.php'" onmouseover="this.className='on'" onmouseout="this.className='off'">
Contact</td>
</tr>
<tr>
<td class="tekst" colspan="3">
<form method="post" action="">
<table style="width: 100%" border="0">
<tr>
<td valign="bottom">Naam</td>
<td><?php echo "$foutnaam <BR />" ?> <input name="naam" type="text" style="width: 400px"></td>
</tr>
<tr>
<td valign="bottom">E-mailadres</td>
<td><?php echo "$foutemail <BR />" ?> <input name="email" type="text" style="width: 400px"></td>
</tr>
<tr>
<td valign="bottom">Onderwerp</td>
<td><?php echo "$foutonderwerp <BR />" ?> <input name="onderwerp" type="text" style="width: 400px"></td>
</tr>
<tr>
<td valign="bottom">Bericht</td>
<td><?php echo "$foutbericht <BR />" ?> <textarea name="bericht" style="width: 400px; height: 150px"></textarea></td>
</tr>
<tr>
<td valign="bottom"> </td>
<td><input name="Submit" type="submit" value="Verzenden"></td>
</tr>
</table>
</form>
<?php
}
?> </td>
</tr>
</table>
</center>
</body>
</html>