开发者

php- changing text box's to already known values

开发者 https://www.devze.com 2023-03-19 21:54 出处:网络
hey guys I have a chunk of code here that takes three values and creates sub domains based off of the entries.i was wondering how i could take the idea of this form and modify it.specifically what i a

hey guys I have a chunk of code here that takes three values and creates sub domains based off of the entries. i was wondering how i could take the idea of this form and modify it. specifically what i am trying to do is put in php variables where the text entry box's are. can any expert reply and tell me how this could be done?

<form method="post" action="<?php echo network_admin_url('site-new.php?action=add-site'); ?>">
<?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ) ?>
    <table class="form-table">
        <tr class="form-field form-required">
            <th scope="row"><?php _e( 'Site Address' ) ?></th>
            <td>
            <?php if ( is_subdomain_install() ) { ?>
                <input name="blog[domain]" type="text" class="regular-text" title="<?php _e( 'Domain' ) ?>"/>.<?php echo preg_replace( '|^www\.|', '', $current_site->domain );?>
            <?php } else {
                echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php _e( 'Domain' ) ?>"/>
            <?php }
            echo '<p>' . __( 'Only the characters a-z and 0-9 recommended.' ) . '</p>';
            ?>
            </td>
        </tr>
        <tr class="form-field form-required">
            <th scope="row"><?php _e( 'Site Title' ) ?></th>
            <td><input name="blog[title]" type="text" class="regular-text" title="<?php _e( 'Title' ) ?>"/></td>
        </tr>
        <tr class="form-field form-required">
     开发者_Go百科       <th scope="row"><?php _e( 'Admin Email' ) ?></th>
            <td><input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>"/></td>
        </tr>
        <tr class="form-field">
            <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ) ?><br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td>
        </tr>
    </table>
    <?php submit_button( __('Add Site'), 'primary', 'add-site' ); ?>


<input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>" value="<?php _e($array['Email']);?>"/>

$array['Email'] is variable where you hold data that should be prefiled or it can be $email


Not sure if that's what you want, but you can output static string instead of input box like this:

instead of:

<input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>"/>

use

//usual syntax
<?php echo $blog['email']; ?>
//short syntax
<?= $blog['email'] ?>

or use Senad Meškin' solution to set default value to your input box.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号