在此站點Site有4個複選框。此時複選框值不會顯示在電子郵件中。 需要做些什麼才能獲得電子郵件中的複選框值?在電子郵件中顯示覆選框值
這是整個代碼kontakt.phpsendmail.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>
sendmail.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;
}
}
}
?>
這是整個代碼kontakt.phpsendmail.class.php
你想如何讓他們顯示在電子郵件?逗號分隔? – KyleK
interessen將是一個數組,看起來像你把它當作一個字符串處理?而在全班學生中,我不知道你在哪裏設置這個價值。 – somedev
在你的'sendmail.class.php'中,你不需要檢索'$ _POST ['interessen']'',它是一個數組。您需要將其添加到加載後值的函數中,並在其上調用'implode()'來返回一個字符串。 –