Manni: (Fast) alle PHP-Scripte bringen Fehlermeldung ...

Beitrag lesen

Hallo Juan,

dass das Formular funktioniert ist schon einmal beruhigend. Vorziehen würde ich allerdings das unten stehende Script, das die Fehlermeldung bringt:

Fatal error: Undefined class name 'oocategory' in /home/www/web00/html/php-test.php on line 36

Die Datei funktioniert _definitiv_, nur bei mir nicht. Ist die Ursache genauso simpel wie im ersten Script?

Herzliche Grüße
Manni

<!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=iso-8859-1"/>  
  <title>PHP-Test</title>  
 </head>  
  
 <body>  
<?php  
// ab hier unbedingt anpassen  
  
# Adresse, an die die Formulardaten gesendet werden sollen:  
$mailto = "info@xxxx.xxx";  
  
// Hier eine Emailadresse eingeben, die der Anfragende als Absende-Emailadresse sehen soll:  
$absender = "info@xxxxx.xxx";  
$absendername = "xxxxx xxxxxx";  
  
// Erlaubt das Versenden nur von dieser URL... (SPAM protection!, ungetestet !)  
$spam_protection = false;  
$iplocal = "123.123.123.123";  
$ipadresse = $REMOTE_ADDR;  
  
// Anhänge erlauben (true/false)  
$attach = true;  
  
# Maximale Größe des Attachments in Bytes:  
$max_attach_size = 1000000;  
  
//ENDE - ab hier unbedingt anpassen  
  
  
// Auslesen der ID dieses Artikels  
$home = OOCategory::getCategoryById($this->getValue("category_id"));  
?>  
  
<style type="text/css">  
<!--  
.caution { color: red; font-weight: bold; }  
-->  
</style>  
<table border="0" cellpadding="0" cellpadding="0" width="330"><tr>  
<td>  
  
<?php  
// stops at once if script was not called from the address $refer_from  
if ($spam_protection) { if ( !eregi( $ipadresse, $iplocal ) ) exit; }  
if (empty($_POST['form_submitted']))  
{  
?>  
  
<p><b>  
Geben Sie im Formular bitte Ihren Namen und Ihren Text ein.  
</b></p>(* = Eingabe erforderlich)<br /><br /><?php  
}  
  
if (isset($_POST["form_submitted"]))  
{  
// übergebene Variablen ermitteln:  
$name = $_POST['name'];  
$email = $_POST['email'];  
$subject = $_POST['subject'];  
$text = $_POST['text'];  
  
// Überprüfungen der Daten:  
unset($errors);  
if ($name == "") $errors[] = "Geben Sie bitte Ihren Namen ein";  
if ($email != "" and !preg_match("/^[^@]+@.+\.\D{2,5}$/", $email)) $errors[] = "Die E-Mail-Adresse sieht nicht richtig aus";  
if ($text == "") $errors[] = "Was wollten Sie uns mitteilen ? Geben Sie bitte Ihre Nachricht ein";  
if ($_FILES['probe']['size'] > $max_attach_size) $errors[] = "Anhang zu groß (".number_format($_FILES['probe']['size']/1000,0,",","")." KB) - Maximalgröße: ".number_format($max_attach_size/1000,0,",","")." KB";  
  
if (empty($errors))  
{  
$text = stripslashes($text);  
$subject = stripslashes($subject);  
if ($subject != "") $mail_subject = $subject; else $mail_subject = "Nachricht von Ihrem Formular";  
if ($email != "") $mail_email = $email; else $mail_email = "email@unbekannt.xyz";  
$ip = $_SERVER["REMOTE_ADDR"];  
  
// Wenn Attachment, dann MIME-Mail erstellen:  
if (isset($_FILES['probe']['name']) && trim($_FILES['probe']['name']) != "")  
{  
// Datei einlesen und codieren:  
$datei_content = fread(fopen($_FILES['probe']['tmp_name'],"r"),filesize($_FILES['probe']['tmp_name']));  
$datei_content = chunk_split(base64_encode($datei_content),76,"\n");  
  
// Boundary festlegen:  
$boundary = md5(uniqid(rand()));  
  
// Mail-Header:  
$mail_header = "From: ".$mail_name." <".$mail_email.">\n";  
$mail_header .= "X-Sender-IP: ".$ip."\n";  
$mail_header .= "MIME-Version: 1.0\n";  
$mail_header .= "Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";  
$mail_header .= "This is a multi-part message in MIME format.\n";  
// Mail-Text:  
$mail_header .= "--".$boundary;  
$mail_header .= "\nContent-Type: text/plain";  
$mail_header .= "\nContent-Transfer-Encoding: 8bit";  
$mail_header .= "\n\nName: ".$name."\n\n".$text;  
// Attachment:  
$mail_header .= "\n--".$boundary;  
$mail_header .= "\nContent-Type: ".$_FILES['probe']['type']."; name=\"".$_FILES['probe']['name']."\"";  
$mail_header .= "\nContent-Transfer-Encoding: base64";  
$mail_header .= "\nContent-Disposition: attachment; filename=\"".$_FILES['probe']['name']."\"";  
$mail_header .= "\n\n".$datei_content;  
  
// Ende:  
$mail_header .= "\n--".$boundary."--";  
// Sende E-Mail und gebe Fehler bzw. Bestaetigung aus  
if (@mail($mailto,$mail_subject,"",$mail_header)) $sent = true; else $errors[] = "Keine Verbindung zum Mailserver - bitte nochmal versuchen";  
}  
// kein Attachment, normale E-Mail:  
else  
{  
$mail_header = "From: ".$mail_name." <".$mail_email.">\n";  
$mail_header .= "X-Sender-IP: $ip\n";  
$mail_header .= "Content-Type: text/plain";  
if (@mail($mailto,$mail_subject,$text,$mail_header)) $sent = true; else $errors[] = "Keine Verbindung zum Mailserver - bitte nochmal versuchen";  
}  
  
// Kopie an Absender:  
if (isset($sent) && isset($email) && $email != "" && isset($_POST['copy']))  
{  
if (isset($_FILES['probe']['name']) && trim($_FILES['probe']['name']) != "") $copy_mail_text = "Kopie der versendeten E-Mail:\n\nName: ".$name."\n\n".$text."\n\nAttachment: ".$_FILES['probe']['name']; else $copy_mail_text = "Kopie der versendeten E-Mail an $absendername :\n\nName: ".$name."\n\n".$text;  
$header= "From: ".$absender."\n";  
$header .= "X-Sender-IP: ".$ip."\n";  
$header .= "Content-Type: text/plain";  
@mail($email, $mail_subject, $copy_mail_text, $header);  
}  
}  
}  
  
if (empty($sent))  
{  
if(isset($errors))  
{  
?><p class="caution">Fehler:</p><ul><?php foreach($errors as $f) { ?><li><?php echo $f; ?></li><?php } ?></ul><br /><?php  
}  
  
?><form method="post" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">  
<input class="hide" type="hidden" name="article_id" value="<?php echo $home->getId(); ?>" />  
<input class="hide" type="hidden" name="FORM[send]" value="1" />  
<input class="hide" type="hidden" name="clang" value="'.$REX['CUR_CLANG'].'" />  
  
<div>  
<b><div id="cont_bez">Name:*</b></div><div id="cont_input"><input type="text" name="name" value="<?php if (isset($name)) echo htmlentities(stripslashes($name)); else echo ""; ?>" size="50" /></div>  
<div id="cont_bez"><b>E-Mail:</b></div><div id="cont_input"><input type="text" name="email" value="<?php if (isset($email)) echo htmlentities(stripslashes($email)); else echo ""; ?>" size="50" /></div>  
<div id="cont_bez"><b>Betreff: &nbsp;</b></div><div id="cont_input"><input type="text" name="subject" value="<?php if (isset($subject)) echo htmlentities(stripslashes($subject)); else echo ""; ?>" size="50" /></div>  
<p><b>Ihr Text:*</b><br /><textarea name="text" cols="40" rows="8"><?php if (isset($text)) echo htmlentities(stripslashes($text)); else echo ""; ?></textarea></p>  
<?php  
if ($attach) {  
?>  
<p><b>PDF/DOC/ZIP als Anhang mitschicken:</b> &nbsp;(max: <?php echo $max_attach_size; ?> Byte)<br /><input type="file" name="probe" value="<?php if (isset($_POST['probe'])) echo htmlentities(stripslashes($_POST['probe'])); else echo ""; ?>" size="30"/></p>  
<?php  
} // if ($attach)  
?>  
<br />  
<p><input type="submit" name="form_submitted" value="Absenden" /> <input type="checkbox" name="copy" value="true" /> Kopie an Absender</p>  
</div></form><?php  
}  
else  
{  
if (empty($email)) { ?>  
<p><b>Danke!</b><br /><br /><br />Nachricht erfolgreich versendet. Allerdings wurde keine E-Mail-Adresse angegeben, wir können also nicht per Email antworten.</p><?php }  
else { ?><p><b>Danke!</b><br /><br /><br />Nachricht erfolgreich versendet.</p>  
<?php }  
}  
?>  
  
</td></tr></table>  
</body>

</html>