<html>
<head>
<title>Eksempel på en PHP formmail</title>
</head>
<body>
<p><strong><big>Eksempel på en formmail i PHP</big><big>:</big> <br>
<a href="formmail.htm">Se PHP/HTML kode</a></p>
<br>
Send os en besked:
</strong></p>
<? //Her starter PHP kode
$OK = 0;
if ($formpress == "Y")
{
$OK = 1;
if (empty($email))
{
print "Skriv e-mail!<BR>";
$OK = 0;
}
if (empty($navn))
{
print "Skriv navn!<BR>";
$OK = 0;
}
if ($OK == 1)
{
$my_email = "mig@min-email.dk";
$to_name = $navn;
$to_email = $email;
$headers = "From: ".$my_name." <".$my_email.">\r\n";
$subject = "E-mail fra hjemmeside ang.: $ang";
$message = "Navn : $navn\n\r";
$message .= "Adr : $adresse\r\n";
$message .= "By : $by\r\n";
$message .= "Tlf : $tlf\r\n\r\n";
$message .= "Andet:\r\n$andet";
if (mail($to_email, $subject, $message, $headers))
{
print "Tak vi har modtaget din besked ang.: $ang";
}
else
{
print "Der er desværre sket en fejl og vi har ikke modtaget din besked!";
}
}
}
if ($OK == 0)
{
print "<form action='formmail.php' method='POST' name='Send'>";
print "<input type='hidden' name='formpress' value='Y'>";
print "<p>Navn:<br>";
print " <input type='text' name='navn' value='$navn' size='40'><br>";
print " Adresse:<br>";
print " <input type='text' name='adresse' value='$adresse'size='40'><br>";
print " By:<br>";
print " <input type='text' name='by' value='$by' size='40'><br>";
print " Ang:<br>";
print " <select name='ang' size='1'>";
$selected = "";
if ($ang == "Mor") { $selected = " Selected"; }
print "<option$selected>Mor </option>";
$selected = "";
if ($ang == "Far") { $selected = " Selected"; }
print "<option$selected>Far </option>";
$selected = "";
if ($ang == "Søn") { $selected = " Selected"; }
print "<option$selected>Søn </option>";
$selected = "";
if ($ang == "Datter") { $selected = " Selected"; }
print "<option$selected>Datter </option>";
print "</select><br>";
print " Telefon:<br>";
print " <input type='text' name='tlf' value='$tlf' size='40'><br>";
print " Din e-mail:<br>";
print " <input type='text' name='email' value='$email' size='40'><br>";
print " Andet:<br>";
print " <textarea cols='34' rows='6' name='andet'>$andet</textarea></p>";
print " <p><input type='submit' value='send'></p>";
print "</form>";
}
//Slut på PHP kode
?>
<hr>
</body>
</html>