0

我在一个 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 条件插入到输入值中?

4

2 回答 2

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>
于 2013-01-21T13:26:46.607 回答
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> ...
于 2013-01-21T13:28:41.897 回答