ich habe ein kleines Umfrage- bzw Kundenzufriedenheitsmodul mit 10 Fragen geschrieben.
Basis war das Kontaktformular mit Captcha. Soweit läuft auch eingentlich alles,
alle Fragen Werte etc werden Übergeben, nur die Values der Radiobuttons nicht. Ich
bin leider nicht ganz so fit in PHP um das sehen zu können woran es liegen könnte.
Wäre nett wenn ihr das mal gerade testen würdet und mir gegebenenfalls sagt was ich ändern müsste.
LG Percy
Eingabe:
Code: Alles auswählen
Bitte die entsprechenden Felder ausfüllen, da sonst das Kontaktformular nicht funktionsfähig ist.
<br>
<strong>ALLGEMEINE INFORMATIONEN<br>
Bezeichner Namensfeld:
<br><input type=text size=20 class=inp100 name=VALUE[1] value="REX_VALUE[1]"><br>
Bezeichner EMail-feld:
<br><input type=text size=20 class=inp100 name=VALUE[2] value="REX_VALUE[2]"><br>
Bezeichner Text-/Nachrichtenfeld:
<br><input type=text size=20 class=inp100 name=VALUE[3] value="REX_VALUE[3]"><br>
Aufschrift auf Senden-Button:
<br><input type=text size=10 class=inp100 name=VALUE[4] value="REX_VALUE[4]"><br>
<strong>FRAGEN<br><br>
Frage 1:<br>
<input type=text size=100 class=inp100 name=VALUE[10] value="REX_VALUE[10]"><br>
Frage 2:<br>
<input type=text size=100 class=inp100 name=VALUE[11] value="REX_VALUE[11]"><br>
Frage 3:<br>
<input type=text size=100 class=inp100 name=VALUE[12] value="REX_VALUE[12]"><br>
Frage 4:<br>
<input type=text size=100 class=inp100 name=VALUE[13] value="REX_VALUE[13]"><br>
Frage 5:<br>
<input type=text size=100 class=inp100 name=VALUE[14] value="REX_VALUE[14]"><br>
Frage 6:<br>
<input type=text size=100 class=inp100 name=VALUE[15] value="REX_VALUE[15]"><br>
Frage 7:<br>
<input type=text size=100 class=inp100 name=VALUE[16] value="REX_VALUE[16]"><br>
Frage 8:<br>
<input type=text size=100 class=inp100 name=VALUE[17] value="REX_VALUE[17]"><br>
Frage 9:<br>
<input type=text size=100 class=inp100 name=VALUE[18] value="REX_VALUE[18]"><br>
Frage 10:<br>
<input type=text size=100 class=inp100 name=VALUE[19] value="REX_VALUE[19]"><br>
<strong>MAIL VERSAND<br><br>
E-Mailadresse an die das Formular versendet werden soll:
<br><input type=text size=40 class=inp100 name=VALUE[7] value="REX_VALUE[7]"><br><br>
E-Mailadresse(n) an die das Formular als Kopie versendet werden soll (mehrer Empfänger bitte mit , trennen):
<br><input type=text size=40 class=inp100 name=VALUE[8] value="REX_VALUE[8]"><br><br>
Titel der EMail:
<br><input type=text size=40 class=inp100 name=VALUE[9] value="REX_VALUE[9]"><br><br>
<strong>MELDUNGEN<br><br>
Meldung bei nicht korrekt ausgefülltem Formular:
<br><textarea name=VALUE[5] cols=80 rows=2 class=inp100>REX_VALUE[5]</textarea><br><br>
Meldung bei erfolgreicher Versendung des Formulars:
<br><textarea name=VALUE[6] cols=80 rows=2 class=inp100>REX_VALUE[6]</textarea><br><br>
Code: Alles auswählen
<?php
session_start();
// ============== Form config ==============
// Daten für die Ausgabe der Fehlermeldung,
// Überschrift, Legend, Beschreibung, Feldnamen, "Submit"-Button
$page_info = "";
$hack_message = "REX_VALUE[5]";
//Formular
$form_header = "";
$form_legend = "";
$form_info = "";
$form_name = "REX_VALUE[1]";
$form_firma = "";
$form_email = "REX_VALUE[2]";
$form_message = "REX_VALUE[3]";
$submit_value = "REX_VALUE[4]";
$submit_titel = "Zum Absenden bitte nur 1x klicken";
$form_frage1 = "REX_VALUE[10]";
$form_frage2 = "REX_VALUE[11]";
$form_frage3 = "REX_VALUE[12]";
$form_frage4 = "REX_VALUE[13]";
$form_frage5 = "REX_VALUE[14]";
$form_frage6 = "REX_VALUE[15]";
$form_frage7 = "REX_VALUE[16]";
$form_frage8 = "REX_VALUE[17]";
$form_frage9 = "REX_VALUE[18]";
$form_frage10 = "REX_VALUE[19]";
// Danke-Seite
$thanks_message = "REX_VALUE[6]";
// Empfänger E-Mail
$empfaenger="REX_VALUE[7]";
$empfaengerBC="REX_VALUE[8]";
$email_titel="REX_VALUE[9]";
// ============== Ende Form config ==============
// Daten aus Form config konvertieren
if ( !function_exists('clean_text')) {
function clean_text($value = "")
{
$value = htmlentities($value);
return $value;
}
}
$page_info = clean_text($page_info);
//$hack_message = clean_text($hack_message);
$form_legend = clean_text($form_legend);
//$form_name = clean_text($form_name);
//$form_email = clean_text($form_email);
$form_firma = clean_text($form_firma);
$form_message = clean_text($form_message);
$submit_value = clean_text($submit_value);
//$submit_titel = clean_text($submit_titel);
//$thanks_message = clean_text($thanks_message);
// ============== Formularüberprüfung ==============
if (!function_exists ('cleanup')) {
function cleanup($string) {
// falls magic quotes on
if (get_magic_quotes_gpc())
{
$string = stripslashes($string);
}
$string = addslashes($string);
$string = strip_tags($string);
// "--","#";";","`","/" Ausfiltern von SQL-Statements
$string = str_replace(array("--","- -","#",";","`","/","<",">","{","}","[","]"),array("","","","","","","","","","","",""),$string);
// - mit Leerzeichen dazwischen (SQL-Kommentare!)
$string = preg_replace('#-\s+-#i',"",$string);
return $string;
} // end function cleanup
} // if (!function_exists ('cleanup'))
if (!function_exists ('checkName')) {
function checkName($string) {
// $name am Anfang Buchstabe; keine Zahlen und Nicht-Wortzeichen; dann
// beliebig viele Buchstaben, Bindestriche, Leerzeichen und Punkte
if (preg_match("/^[^\W\d_]([^\W\d_]|[\-\'\ä\Ä\ö\Ö\ü\Ü\s\.\?\?\?\?\?\?\?])*$/", stripslashes($string)))
{
return true; // OK
} else {
return false; // falsche Eingabe
}
} // end function checkName
} // if (!function_exists ('checkName'))
if (!function_exists ('checkNumeric')) {
function checkNumeric($string) {
// nur Zahlenr
if (preg_match("/^\d*$/", stripslashes($string)))
{
return true; // OK
} else {
return false; // falsche Eingabe
}
} // end function checkNumeric
} // if (!function_exists ('checkNumeric'))
if (!function_exists ('checkEmail')) {
function checkEmail($string) {
// $email mindestens a@a.aa
if (ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([_a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$", stripslashes($string)))
{
return true; // OK
} else {
return false; // falsche Eingabe
}
} // end function checkEmail
} // if (!function_exists ('checkEmail'))
if (!function_exists ('checkMessage')) {
function checkMessage($string) {
// $email mindestens a@a.aa
if (preg_match("/^[^\d_]([^\W]|[\-\'\ä\Ä\ö\Ö\ü\Ü\s\"\.\!\?\;\,\:\?\%\(\)\+\=\@\*\?\?\?\?\?\?\?])*$/", stripslashes($string)))
{
return true; // OK
}
else
{
return false; // falsche Eingabe
}
} // end function checkMessage
} // if (!function_exists ('checkMessage'))
$hack = false; // Bool'sche Variable zeigt an, ob
// ein Hackingversuch vorliegt
// Auslesen und Säubern der Daten aus $_POST
if (sizeof($_POST) == 0)
{
$name = "";
$firma = "";
$email = "";
$frage1 = "";
$frage2 = "";
$frage3 = "";
$frage4 = "";
$frage5 = "";
$frage6 = "";
$frage7 = "";
$frage8 = "";
$frage9 = "";
$frage10 = "";
$message = "";
$submit = "";
} else {
$name = $_POST["name"];
$email = $_POST["email"];
$firma = $_POST["firma"];
$frage1 = $_POST["frage1"];
$frage2 = $_POST["frage2"];
$frage3 = $_POST["frage3"];
$frage4 = $_POST["frage4"];
$frage5 = $_POST["frage5"];
$frage6 = $_POST["frage6"];
$frage7 = $_POST["frage7"];
$frage8 = $_POST["frage8"];
$frage9 = $_POST["frage9"];
$frage10 = $_POST["frage10"];
$message = $_POST["message"];
$submit = $_POST["submit"];
$sicherheit = $_POST["sicherheitscode"];
$name = cleanup($name);
$email = cleanup($email);
$firma = cleanup($firma);
$frage1 = cleanup($frage1);
$frage2 = cleanup($frage2);
$frage3 = cleanup($frage3);
$frage4 = cleanup($frage4);
$frage5 = cleanup($frage5);
$frage6 = cleanup($frage6);
$frage7 = cleanup($frage7);
$frage8 = cleanup($frage8);
$frage9 = cleanup($frage9);
$frage10 = cleanup($frage10);
$message = cleanup($message);
$submit = cleanup($submit);
// Verifizieren der Daten
if(isset($_SESSION['captcha_spam']) AND $_POST["sicherheitscode"] == $_SESSION['captcha_spam']){
unset($_SESSION['captcha_spam']); } else {
$hack = true; $feld = 'Sicherheitscode';
}
if (checkName($name)!=1)
{
$hack = true; $feld = $form_name;
}
if (checkEmail($email)!=1)
{
$hack = true; $feld = $form_email;
}
if (checkMessage($message)!=1)
{
$hack = true; $feld = $form_message;
}
} // end else
// ============== Ende FormularÜberprüfung ==============
?>
<?php
// beim ersten Aufruf oder unkorrekten Eingaben Formular ausgeben
if (($submit == "") OR (($submit == $submit_value) AND ($hack == true)))
{
// Bei inkorrekten Eingaben eine Fehlermeldung ausgeben:
if ($hack)
{
?>
<p><?php echo $hack_message; ?></p>
<ul>
<li><?php echo $feld; ?></li>
</ul>
<?php
} // end if ($hack)
else
{
if ($page_info != "")
{
echo "<p>" . $page_info . "</p>\n";
}
} // end else
?>
<div id="umfrage">
<form id="kontakt" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<fieldset>
<?php
echo "<legend><strong>" . $form_legend . "</strong></legend>\n";
?>
<label for="name"><strong><?php echo $form_name; ?></strong></label><br />
<input class="inpt" type="text" id="name" name="name" size="38" title="<?php echo $form_name; ?>" value="<?php echo stripslashes($name); ?>" tabindex="1" /><br /><br />
<label for="email"><strong><span lang="en"><?php echo $form_email; ?></span></strong></label><br />
<input class="inpt" type="text" id="email" name="email" size="38" title="<?php echo $form_email; ?>" value="<?php echo stripslashes($email); ?>" tabindex="2" /><br /><br />
<!-- ============== ANFANG DER FRAGEN ============== //-->
<table border="0" cellspacing="0" cellpadding="10">
<tr>
<td width="600" align="left" scope="col"> </th>
<td width="30" align="center" scope="col">1</th>
<td width="30" align="center" scope="col">2</th>
<td width="30" align="center" scope="col">3</th>
<td width="30" align="center" scope="col">4</th>
<td width="30" align="center" scope="col">5</th>
<td width="30" align="center" scope="col">6</th>
</tr>
<tr bgcolor="#66CCFF">
<td width="600" align="left" scope="row"><strong><?php echo $form_frage1; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage1); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage1); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage1); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage1); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage1); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage1); ?>" value="6" /></td>
</tr>
<tr>
<td width="600" align="left" scope="row"><?php echo $form_frage2; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage2); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage2); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage2); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage2); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage2); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage2); ?>" value="6" /></td>
</tr>
<tr bgcolor="#66CCFF">
<td width="600" align="left" scope="row"><?php echo $form_frage3; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage3); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage3); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage3); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage3); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage3); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage3); ?>" value="6" /></td>
</tr>
<tr>
<td width="600" align="left" scope="row"><?php echo $form_frage4; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage4); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage4); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage4); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage4); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage4); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage4); ?>" value="6" /></td>
</tr>
<tr bgcolor="#66CCFF">
<td width="600" align="left" scope="row"><?php echo $form_frage5; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage5); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage5); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage5); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage5); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage5); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage5); ?>" id="radio30" value="6" /></td>
</tr>
<tr>
<td width="600" align="left" scope="row"><?php echo $form_frage6; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage6); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage6); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage6); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage6); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage6); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage6); ?>" value="6" /></td>
</tr>
<tr bgcolor="#66CCFF">
<td width="600" align="left" scope="row"><?php echo $form_frage7; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage7); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage7); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage7); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage7); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage7); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage7); ?>" value="6" /></td>
</tr>
<tr>
<td width="600" align="left" scope="row"><?php echo $form_frage8; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage8); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage8); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage8); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage8); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage8); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage8); ?>" value="6" /></td>
</tr>
<tr bgcolor="#66CCFF">
<td width="600" align="left" scope="row"><?php echo $form_frage9; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage9); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage9); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage9); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage9); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage9); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage9); ?>" value="6" /></td>
</tr>
<tr>
<td width="600" align="left" scope="row"><?php echo $form_frage10; ?></strong></th>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage10); ?>" value="1" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage10); ?>" value="2" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage10); ?>" value="3" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage10); ?>" value="4" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage10); ?>" value="5" /></td>
<td width="30" height="30" align="center"><input type="radio" name="<?php echo stripslashes($form_frage10); ?>" value="6" /></td>
</tr>
</table>
<!-- ============== ENDE DER FRAGEN ============== //-->
<label for="message"><strong><?php echo $form_message; ?></strong></label><br />
<textarea class="txt" id="message" name="message" title="<?php echo $form_message; ?>" cols="36" rows="8" tabindex="3"><?php echo stripslashes($message); ?></textarea><br /><br />
<label for="captcha"><strong>Sicherheitscode</strong></label><br /><?php if($REX['REDAXO'] ==0) {
?><img src="captcha/captcha.php" border="0" title="Sicherheitscode" align="left"><input type="text" name="sicherheitscode" size="4"><?php } ?><br /><br />
<input type="submit" class="senden" name="submit" value="<?php echo $submit_value; ?>" title="<?php echo $submit_titel; ?>" tabindex="4" /><br />
</fieldset>
</form>
</div>
<?php
} // if (($submit == "") OR (($submit == $submit_value) AND ($hack == true)))
elseif (($submit == $submit_value) AND ($hack == false))
{
//email abschicken
$recipient=$empfaenger;
$subject=$email_titel;
$header="From: " . $email . "\n";
$mail_body ="Die Kundenumfrage wurde am " . date("d.m.Y") . " um " . date("H:i") . "h ausgeführt.\n";
$mail_body.="Folgende Werte wurden eingetragen:\n\n";
$mail_body.="Name: " . $name . "\n";
$mail_body.="E-Mail: " . $email . "\n\n";
$mail_body.="". $form_frage1 . "\n";
$mail_body.="". $form_frage2 . "\n";
$mail_body.="". $form_frage3 . "\n";
$mail_body.="". $form_frage4 . "\n";
$mail_body.="". $form_frage5 . "\n";
$mail_body.="". $form_frage6 . "\n";
$mail_body.="". $form_frage7 . "\n";
$mail_body.="". $form_frage8 . "\n";
$mail_body.="". $form_frage9 . "\n";
$mail_body.="". $form_frage10 . "\n\n";
$mail_body.="Sonstige Anmerkungen: \n" .$message . "\n\n";
mail($recipient,$subject,$mail_body,$header);
if ($empfaengerBC != ''){
$recipient=$empfaengerBC;
mail($recipient,$subject,$mail_body,$header);
}
echo '<br /><br /><p class="center"><strong>'.$thanks_message.'</strong></p>'."\n";
}
?>