Hallo
Und nochmal ich^^
Habe nach diesem Tutorial:http://www.dreamweavertutorial.co.uk/dreamweaver/video/contact-form-php-validation.htm
Ein Kontaktformular gebaut.
Code:
Allerdings bekomme ich in Zeile 175 einen Error mit dem PHP Code
und wegen dem PHP Code in Zeile 184 bekomme ich in Zeile 188 einen Syntax Fehler.
Weiß jemand wo ich einen Fehler gemacht habe?
Danke
/E
Kontaktformular scipt beginnt in Zeile 43
Und nochmal ich^^
Habe nach diesem Tutorial:http://www.dreamweavertutorial.co.uk/dreamweaver/video/contact-form-php-validation.htm
Ein Kontaktformular gebaut.
Code:
PHP:
<?PHP
header('Content-Type: text/html; charset=UTF-8'); // Umlaute richtig anzeigen
$Pages = array(); // Array, welches die erlaubten Seitennamen enthält (Anfangs jedoch leer)
function registerPages() {
global $Pages;
$pageHandle = opendir('./pages/');
while($phPage = readdir($pageHandle)) {
if($phPage != '.' && $phPage != '..' && $phPage != '.htaccess' && $phPage && is_dir('./pages/'.$phPage)===false) { /* Hier wird geprüft, dass keine Ordner ausgewählt werden, ausserdem keine [I].[/I] , [I]..[/I] oder [I].htaccess[/I] */
$phKey = substr($phPage,0,strpos($phPage,'.')); // Dateinamen (ohne .php)
$Pages[$phKey] = $phPage; /* Dateiname (ohne .php) ist der Schlüssel zum echten Dateinamen (mit .php) */
}
}
closedir($pageHandle);
}
registerPages(); // Array füllen
function cP($page) { // überprüft ob eine solche Datei verfügbar ist
global $Pages;
if(is_file('./pages/'.$Pages[$page])) {
return true;
}
else {
return false;
}
}
function gP($page) { // falls die Datei vorhanden ist, wird der Name der Datei ausgegeben, sonst eine Fehlerseite
global $Pages;
if(cP($page)) {
return $Pages[$page]; // richtigen Dateinamen ausgeben
}
else {
echo "<p>Hmm, da ist was schief gelaufen...<br />
Schicke mir doch bitten den Fehlercode da unten an admin@adhsclan.tk damit ich den Fehler
so schnell wie möglich beheben kann.</p>";
// return 'error.php'; // Fehlerseite ausgeben (Name auch änderbar)
}
}
?>
<?php
// Set email variables
$email_to = 'admin@adhsclan.tk';
$email_subject = 'Kontaktformular';
// Set required fields
$required_fields = array('fullname','email','comment');
// set error messages
$error_messages = array(
'fullname' => 'Bitte geben sie ihren Namen ein.',
'email' => 'Bitte geben sie eine gültige E-mail ein.',
'comment' => 'Bitte geben sie eine gültige Nachricht ein.'
);
// Set form status
$form_complete = FALSE;
// configure validation array
$validation = array();
// check form submittal
if(!empty($_POST)) {
// Sanitise POST array
foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value));
// Loop into required fields and make sure they match our needs
foreach($required_fields as $field) {
// the field has been submitted?
if(!array_key_exists($field, $_POST)) array_push($validation, $field);
// check there is information in the field?
if($_POST[$field] == '') array_push($validation, $field);
// validate the email address supplied
if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
}
// basic validation result
if(count($validation) == 0) {
// Prepare our content string
$email_content = 'Eine neue Nachricht über das Kontaktformular: ' . "\n\n";
// simple email content
foreach($_POST as $key => $value) {
if($key != 'submit') $email_content .= $key . ': ' . $value . "\n";
}
// if validation passed ok then send the email
mail($email_to, $email_subject, $email_content);
// Update form switch
$form_complete = TRUE;
}
}
function validate_email_address($email = FALSE) {
return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
}
function remove_email_injection($field = FALSE) {
return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>adHs-clan</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="contact/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"></script>
<script type="text/javascript" src="contact/validation/validation.js"></script>
<script type="text/javascript">
var nameError = 'Bitte geben sie ihren Namen ein.';
var emailError = 'Bitte geben sie eine gültige E-mail ein.';
var commentError = 'Bitte geben sie eine gültige Nachricht ein.';
var phoneError = 'Bitte geben sie eine gültige Nachricht ein.';
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
</script>
<link rel="shortcut icon" href="favicon.png
">
</head>
<body>
<div id="site">
<header>
<div align="right"><a href="index.php?page=home"><img src="img/logo.png" width="337" height="136" align="left" /></a><a href="#facebook#"><img src="img/facebook.png" width="495" height="60" /></a><a href="#youtube#"><img src="img/youtube.png" width="495" height="60" /></a><a href="#rss#"><img src="img/rss.png" width="495" height="60" /></a></div>
</header>
<div id="contentbg">
<nav><a href="index.php?page=home" class="home-link home"></a><a href="index.php?page=about" class="about-link about"></a><a href="forum/index.php" class="forum-link forum"></a><a href="index.php?page=joinus" class="joinus-link joinus"></a><a href="index.php?page=teamspeak" class="teamspeak-link teamspeak"></a><a href="contact.php" class="kontakt-link kontakt"></a></nav>
<section id="content">
<div id="formWrap">
<h2>Kontakt</h2>
<div id="form">
<form action="contact.php" method="post" id="comments_form">
<div class="row">
<div class="label">Ihr Name</div> <!-- end .label -->
<div class="input">
<input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /><?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?>
</div><!-- end .input -->
<div class="context">Max Mustermann</div><!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Ihre E-mail Adresse</div> <!-- end .label -->
<div class="input">
<input type="text" id="email" class="detail" name="email" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?> </div><!-- end .input -->
<div class="context">Wer werden ihre Daten nicht an 3. weitergeben.</div><!-- end .context -->
</div><!-- end .row -->
<div class="row">
<div class="label">Ihre Nachricht</div> <!-- end .label -->
<div class="input2">
<textarea id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea><?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?>
</div><!-- end .input -->
</div><!-- end .row -->
<div class="submit">
<input type="submit" id="submit" name="submit" value="Nachricht Senden" /><?php else: ?>
<p>Vielen Dank für ihre Nachricht</p>
<?php endif; ?>
</div><!-- end .submit -->
</form>
</div><?php if($form_complete === FALSE): ?><!-- end#form -->
</div><!-- end #formWrap -->
<h6 align="right" class="center"><small><a href='javascript:scroll(0,0);'>nach oben</a></small></h6>
</section>
<footer>
<hr />
<p align="center">
| © 2012 | <a href="index.php?page=impressum">adHs-Clan</a> is powered by Rekor - Alle Rechte vorbehalten | Design © <a href="#">Hwexxy</a> |
<p align="center"><a href="index.php?page=impressum">Impressum</a> - <a href="index.php?page=kontakt">Kontakt</a> - <a href="index.php?page=forum">Forum</a>
<br />
<img src="img/werbungbig.png" alt="WERBUNG" width="468" height="60" /></footer><!--foter-->
</div><!--contentbg-->
</div> <!--divsite-->
</body>
</html>
Allerdings bekomme ich in Zeile 175 einen Error mit dem PHP Code
und wegen dem PHP Code in Zeile 184 bekomme ich in Zeile 188 einen Syntax Fehler.
Weiß jemand wo ich einen Fehler gemacht habe?
Danke
/E
Kontaktformular scipt beginnt in Zeile 43
Zuletzt bearbeitet: