在同一脚本中组合Ajax联系人表单和php邮件程序

在同一脚本中组合Ajax联系人表单和php邮件程序,php,wordpress,email,shortcode,mailer,Php,Wordpress,Email,Shortcode,Mailer,我已经为wordpress创建了一个联系人表单快捷码插件。然而,我遇到的问题是,我似乎无法响应php邮件文件中的短代码参数 例如,我的短代码如下所示: [vc-contact-form title="contact form" recipient_email="email@emailaddress.com] 生成此短代码的PHP代码如下: extract(shortcode_atts(array( 'el_class' => '', 'ti

我已经为wordpress创建了一个联系人表单快捷码插件。然而,我遇到的问题是,我似乎无法响应php邮件文件中的短代码参数

例如,我的短代码如下所示:

[vc-contact-form title="contact form" recipient_email="email@emailaddress.com]
生成此短代码的PHP代码如下:

extract(shortcode_atts(array(
            'el_class' => '',
            'title' => '', 
            'subtitle' => '',
            'recipient_email' => '',
        ), $atts));

        $el_class = $this->getExtraClass($el_class);
        $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG,$el_class, $this->settings['base']);
        $subtitle = '<legend>'.$subtitle.'</legend>';           
        $recipient_email = '<input type="hidden" name="recipient_email" id="recipient_email" value="'.$recipient_email.'" /><br />';

        $output .= '<div class="contact-form '.$css_class.'" >';
        $output .= '<h4 class="form-title">'.$title.'</h4>';            

        $output .=  '<div id="contact">

        <div id="message"></div>

        <form method="post" action="'. VCPB_PLUGIN_URL . 'contact.php' .'" name="contactform" id="contactform">

        <fieldset>';

        $output .= $subtitle;

        $output .= '<label for="name" accesskey="U"><span class="required">*</span> Your Name</label>
        <input name="name" type="text" id="name" size="30" value="" />

        <br />
        <label for="email" accesskey="E"><span class="required">*</span> Email</label>
        <input name="email" type="text" id="email" size="30" value="" />

        <br />
        <label for="phone" accesskey="P"><span class="required">*</span> Phone</label>
        <input name="phone" type="text" id="phone" size="30" value="" />

        <br />
        <label for="comments" accesskey="C"><span class="required">*</span> Your message</label>
        <textarea name="comments" cols="40" rows="5" id="comments" style="width: 350px;"></textarea>

        <p><span class="required">*</span> Are you human?</p>

        <label for="verify" accesskey="V">&nbsp;&nbsp;&nbsp;3 + 1 =</label>
        <input name="verify" type="text" id="verify" size="4" value="" style="width: 30px;" /><br /><br />

        <input type="submit" class="submit" id="submit" value="Submit" />';
        $output .= $recipient_email;
        $output .= '</fieldset>

        </form>

</div>';          
        $output .= '</div>'; /* END .contact-form */
        return $output;             
    }
}

我想知道是否有可能将生成短代码html和php邮件程序的脚本合并到一个文档中,因为我可以在短代码脚本中轻松获取电子邮件地址。这可能吗?我需要对脚本进行什么样的修改

通常在php脚本中包含html脚本。这不能解决您的问题吗?那么您的意思是将它们结合起来,就像不要麻烦使用contact.php并将该页面的内容放在同一个文件中一样?如果是的话,我把什么作为形式行动?不,没关系,我误解了你的问题。我想谷歌搜索如何访问短代码参数并不难?
<div class="contact-form " >
<h4 class="form-title">Contact Form</h4>

    <div id="contact">
        <div id="message"></div>

        <form method="post" action="http://www.skizzar.com/jsdrumming/wp-content/plugins/vc-contact-form/contact.php" name="contactform" id="contactform">

        <fieldset><legend>Please fill in the form below to get in touch with me</legend><label for="name" accesskey="U"><span class="required">*</span> Your Name</label>
        <input name="name" type="text" id="name" size="30" value="" />

        <br />
        <label for="email" accesskey="E"><span class="required">*</span> Email</label>
        <input name="email" type="text" id="email" size="30" value="" />

        <br />
        <label for="phone" accesskey="P"><span class="required">*</span> Phone</label>
        <input name="phone" type="text" id="phone" size="30" value="" />

        <br />
        <label for="comments" accesskey="C"><span class="required">*</span> Your message</label>
        <textarea name="comments" cols="40" rows="5" id="comments" style="width: 350px;"></textarea>

        <p><span class="required">*</span> Are you human?</p>

        <label for="verify" accesskey="V">&nbsp;&nbsp;&nbsp;3 + 1 =</label>
        <input name="verify" type="text" id="verify" size="4" value="" style="width: 30px;" /><br /><br />

        <input type="submit" class="submit" id="submit" value="Submit" /><input type="hidden" name="recipient_email" id="recipient_email" value="sam@skizzar.com" /><br /></fieldset>

        </form>

</div>
</div>
<?php

if(!$_POST) exit;

if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");
$name     = $_POST['name'];
$email    = $_POST['email'];
$phone   = $_POST['phone'];
$comments = $_POST['comments'];
$verify   = $_POST['verify'];

if(trim($name) == '') {
echo '<div class="error_message">Attention! You must enter your name.</div>';
exit();
} else if(trim($email) == '') {
echo '<div class="error_message">Attention! Please enter a valid email address.</div>';
exit();
} else if(trim($phone) == '') {
echo '<div class="error_message">Attention! Please enter a valid phone number.</div>';
exit();
} else if(!is_numeric($phone)) {
echo '<div class="error_message">Attention! Phone number can only contain digits.</div>';
exit();
} else if(!isEmail($email)) {
echo '<div class="error_message">Attention! You have entered an invalid e-mail address, try again.</div>';
exit();
}

if(trim($comments) == '') {
echo '<div class="error_message">Attention! Please enter your message.</div>';
exit();
} else if(!isset($verify) || trim($verify) == '') {
echo '<div class="error_message">Attention! Please enter the verification number.</div>';
exit();
} else if(trim($verify) != '4') {
echo '<div class="error_message">Attention! The verification number you entered is incorrect.</div>';
exit();
}

if(get_magic_quotes_gpc()) {
    $comments = stripslashes($comments);
}


// Configuration option.
$address = 'THIS NEEDS TO BE THE EMAIL ADDRESS FROM THE SHORTCODE';

$e_subject = 'You\'ve been contacted by ' . $name . '.';
$e_body = "You have been contacted by $name, their message is as follows." . PHP_EOL . PHP_EOL;
$e_content = "\"$comments\"" . PHP_EOL . PHP_EOL;
$e_reply = "You can contact $name via email, $email or via phone $phone";

$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );

$headers = "From: $email" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;

if(mail($address, $e_subject, $msg, $headers)) {

// Email has sent successfully, echo a success page.

echo "<fieldset>";
echo "<div id='success_page'>";
echo "<h1>Email Sent Successfully.</h1>";
echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>";
echo "</div>";
echo "</fieldset>";

} else {
echo 'ERROR!';
}
?>
    $address = 'THIS NEEDS TO BE THE EMAIL ADDRESS FROM THE SHORTCODE';