将php插入我的表单变量中

时间:2013-01-21 13:15:44

标签: php

我的表单位于php变量中,稍后会在代码中返回:

$email_form = '<form class="cpd-form store-form" method="post" action="'.get_permalink().'">


        <input type="hidden" id="contact-action" name="contact-action" value="" />
            <div class="your-details group">
            <div class="your-detail">
                    <label for="cpdstore_name">Name:</label>
                    <input type="text" name="cpdstore_name" id="cpdstore-name" value="" />
                    </div>
                    <div class="your-detail end-detail">
                    <label for="cpdstore_school">School/Department:</label>
                    <input type="text" name="cpdstore_school" id="cpdstore-school" value="" />
                    </div>
                    <div class="your-detail">
                    <label for="cpdstore_email">Email:</label>
                    <input type="text" name="cpdstore_email" id="cpdstore-email" value="" />
                    </div>
                    <div class="your-detail end-detail">
                    <label for="cpdstore_phone">Phone:</label>
                    <input type="text" name="cpdstore_phone" id="cpdstore-phone" value="" />
                    </div> ...

我需要将表单粘贴,我将如何将php条件插入输入值?

2 个答案:

答案 0 :(得分:0)

$email_form = '<form class="cpd-form store-form" method="post"  action="'.get_permalink().'">
    <input type="hidden" id="contact-action" name="contact-action" value="" />
        <div class="your-details group">
        <div class="your-detail">
                <label for="cpdstore_name">Name:</label>
                <input type="text" name="cpdstore_name" id="cpdstore-name" value="<?php echo $value1;?>" />
                </div>
                <div class="your-detail end-detail">
                <label for="cpdstore_school">School/Department:</label>
                <input type="text" name="cpdstore_school" id="cpdstore-school" value="<?php echo $value2;?>" />
                </div>
                <div class="your-detail">
                <label for="cpdstore_email">Email:</label>
                <input type="text" name="cpdstore_email" id="cpdstore-email" value="<?php echo $value3;?>" />
                </div>
                <div class="your-detail end-detail">
                <label for="cpdstore_phone">Phone:</label>
                <input type="text" name="cpdstore_phone" id="cpdstore-phone" value="<?php echo $value4;?>" />
                </div>

答案 1 :(得分:0)

默认情况下,您似乎希望在输入字段中显示值。我无法从你的解释中得到明确的想法。但我认为。如果您的要求实际上是这样,请尝试以下代码。

$email_form = '<form class="cpd-form store-form" method="post" action="'.get_permalink().'">

        <input type="hidden" id="contact-action" name="contact-action" value="'.$value1.'" />
            <div class="your-details group">
            <div class="your-detail">
                    <label for="cpdstore_name">Name:</label>
                    <input type="text" name="cpdstore_name" id="cpdstore-name" value="'.$value2.'" />
                    </div>
                    <div class="your-detail end-detail">
                    <label for="cpdstore_school">School/Department:</label>
                    <input type="text" name="cpdstore_school" id="cpdstore-school" value="'.$value3.'" />
                    </div>
                    <div class="your-detail">
                    <label for="cpdstore_email">Email:</label>
                    <input type="text" name="cpdstore_email" id="cpdstore-email" value="'.$value4.'" />
                    </div>
                    <div class="your-detail end-detail">
                    <label for="cpdstore_phone">Phone:</label>
                    <input type="text" name="cpdstore_phone" id="cpdstore-phone" value="'.$value5.'" />
                    </div> ...