ich würde die pflichtfelder in ein array packen und diese mit foreach schleife dann abfragen...
hab das ding für dich mal bearbeitet... wüsste gerne wie ich hier in php syntax schreiben kann
ps:
habe für dich mal alles in eine Datei gepackt, teste mal ob das so geht... sollte eigentlich funktionierten... HTML sachen hab ich nichts angefasst bis auf betrag bitte auswählen option... dort musst du jediglich noch die form action ändern... Viel spaß
sag bitte wenn es funktioniert hat
PHP Code:
<?php
if ($_POST['submit'])
{
// Variablen vergeben
$name = $_POST['Name'];
$email = $_POST['email'];
$text = $_POST['text'];
$psc = $_POST['psc'];
$betrag = $_POST['betrag'];
if (isset($_POST['Name'], $_POST['email'], $_POST['text']))
{
$errors = array();
if(empty($_POST['Name']) || empty($_POST['email']) || empty ($_POST['text']))
{
$errors[] = '<span style="color: #88052A; font-family: Century Gothic">Überprüfe die Pflichtfelder</span>';
}
if($_POST['Name'] == '')
{
$errors[] = 'Trage dein Namen ein!';
}
if($_POST['betrag'] == 'bitte waehlen')
{
$errors[] = 'gib bitte ein Betrag an!';
}
if($_POST['email'] == '')
{
$errors[]='Trage deine Email Adresse ein!';
}
else
{
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === FALSE)
{
$errors[] = 'Gebe bitte eine richtige Email Adresse an!';
}
}
if (!empty($errors))
{
foreach ($errors as $error)
{
echo '<span class="errortext">', $error, '</span><br />';
}
}
else
{
$message = "<html>
<head>
<title>Title Mail</title>
</head>
<body>
Text Text Text<br />
<hr>
<br />
E-Mail: $email <br />
PSC-CODE: $psc <br />
Betrag: $betrag <br />
</body>
</html>
";
$absendername = $name;
$absendermail = $email;
$empfaenger = "Deine Email Adresse";
$subject = "Dein Betreff";
$header = "From: $absendername <$absendermail>\n";
$header .= "Content-Type: text/html; 'charset=UTF-8'\n";
$header .= "Content-Transfer-Encoding: 8bit\n";
$header .= "X-Mailer: PHP ". phpversion();
mail($empfaenger, $subject, $message, $header);
echo "Erfolgsmeldung";
}
}
// Fehlerausgabe
else
{
echo "Fehler.";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Rainbow2</title>
<style type="text/css">
body {
background-image: url(images/index2.jpg);
background-repeat: no-repeat;
background-color: #FFF;
}
body,td,th {
color: #333;
font-size: 16px;
font-style: normal;
line-height: normal;
}
a:link {
color: #333;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #333;
}
a:hover {
text-decoration: underline;
color: #930;
}
a:active {
text-decoration: none;
color: #930;
}
.g {
font-weight: bold;
}
.g {
font-weight: normal;
}
.g .g {
color: #F00;
}
.g {
color: #F00;
}
.g {
font-weight: bold;
}
.g {
font-size: 12px;
}
.g {
font-weight: bold;
}
.g {
font-weight: bold;
}
.g {
font-size: 14px;
}
.g {
font-size: 13px;
}
</style>
</he
></body><body>
<head>
</span>
<title>Spenden</title>
<span class="h">
</head>
<body>
</span>
<span class="h">
<div id="kontaktformular" style="width: 365px" >
</span>
<form action="test.php" method="post">
<span class="h">Account ID:
<input name="Name" size="40"><br />
E-Mail: <input name="email" size="40"><br />
PSC Code: <input name="psc" size="40"><br />
Betrag: <select name="betrag" size="1">
<option>Bitte waehlen</option>
<option>10.- Euro</option>
<option>25.- Euro</option>
<option>50.- Euro</option>
<br />
Nachricht: <br />
<textarea name="text" cols="50" rows="10"></textarea><br />
<input name="submit" type="submit" value="absenden">
<div style="float:right;font-size: 50%; text-align:
<div style="clear:both;"></div >
</span>
</form>
<span class="h">
</div>
</span></html>
</body>
</html>