在php中使用此运算符破坏复选框值

时间:2013-06-12 14:42:55

标签: php html email checkbox

在此联系表单Website Link中,有四个复选框。如何将implode(', ', $interessen);集成到代码部分$message .= "<tr><td><strong>Interessiert an:</strong> </td><td>" . $this->interessen . "</td></tr>";中 我试过,但电子邮件中没有复选框值。

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:

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;
    }
}

目前,值“Interessiert an:”给出一个空字段而不是复选框值。在代码中需要做什么来获取复选框值?

0 个答案:

没有答案