On this site Site there are 4 checkboxes. At the moment the checkbox values are not shown in email. What has to be done to get the checkbox values in the email?
This is the whole code 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>
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;
}
}
}
?>
This is the whole code kontakt.php sendmail.class.php
sendmail.class.php
, you do not retrieve$_POST['interessen']
, which is an array. You will need to add that into the function that loads post values, and callimplode()
on it to return a string. – Michael Berkowski Jun 12 at 16:00var
keyword. php.net/manual/en/language.oop5.basic.php – Michael Berkowski Jun 12 at 16:01