在此站点站点上有 4 个复选框。目前复选框值未显示在电子邮件中。必须做什么才能在电子邮件中获取复选框值?
这是整个代码kontakt.php sendmail.class.php
kontakt.php:
<form action="kontakt.php" method="post">
<label for="name">Ihr Name:</label>
<input type="text" class="get1" name="name" value="<?php echo htmlspecialchars($_POST['name']); ?>" />
<br />
<label for="phone">Telefonnummer (bitte nur Ziffern):</label>
<input type="text" class="get1" name="phone" value="<?php echo htmlspecialchars($_POST['phone']); ?>" />
<br />
<label for="email">E-Mail-Adresse:</label>
<input type="text" class="get1" name="email" value="<?php echo htmlspecialchars($_POST['email']); ?>" />
<br />
<label for="message">Ihre Mitteilung an uns:</label>
<textarea cols="20" rows="5" name="message"><?php echo htmlspecialchars($_POST['message']); ?></textarea>
<br />
<label>Welche Leistungen interessieren Sie besonders?</label>
<label style="display:inline;" for="dachstuehle">Dachstühle</label>
<input class="kaestchen" type="checkbox" name="interessen[]" id="dachstuehle" value="dachstuehle" />
<label style="display:inline;" for="holzbau">Holzbau</label>
<input class="kaestchen" type="checkbox" name="interessen[]" id="holzbau" value="holzbau" />
<label style="display:inline;" for="innenausbau">Innenausbau</label>
<input class="kaestchen" type="checkbox" name="interessen[]" id="innenausbau" value="innenausbau" />
<label style="display:inline;" for="trocken">Trockenbau</label>
<input class="kaestchen" type="checkbox" name="interessen[]" id="trockenbau" value="trockenbau" />
<br /><br />
<input type="hidden" value="1" name="s" />
<input type="submit" value="Nachricht versenden" name="submit" />
</form>
发送邮件.class.php:
<?php
class sendMail {
var $to = 'email'; // set contact email
var $name = '';
var $phone = '';
var $email = '';
var $body = '';
var $interessen = '';
var $error = array();
var $headers = array();
function parseBody() {
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= '<tr style="background-color: #eee;"><td><strong>Name:</strong> </td><td>' . $this->name . '</td></tr>';
$message .= "<tr><td><strong>Telefonnummer:</strong> </td><td>" . $this->phone . "</td> </tr>";
$message .= "<tr><td><strong>E-Mail-Adresse:</strong> </td><td>" . $this->email . "</td></tr>";
$message .= "<tr><td><strong>Text:</strong> </td><td>" . $this->body . "</td></tr>";
$message .= "<tr><td><strong>Interessiert an:</strong> </td><td>" . $this->interessen . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$this->body = $message;
}
function send() {
if ($this->error) {
return FALSE;
}
if (mail($this->to, '=?utf-8?B?' . base64_encode($this->subject) . '?=', $this->body, $this->headers)) {
return TRUE;
} else {
$this->error[] = 'Fehler beim senden';
return FALSE;
}
}
}
?>