[英]php- changing text box's to already known values
嘿伙計們,我這里有一段代碼,它采用三個值並根據條目創建子域。 我想知道我怎么能接受這個表格的想法並修改它。 具體來說,我要做的是放入文本輸入框所在的 php 變量中。 任何專家都可以回復並告訴我如何做到這一點?
<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">
<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'] 是變量,您保存應該預先歸檔的數據,或者它可以是 $email
不確定這是否是您想要的,但您可以使用 output static 字符串代替輸入框,如下所示:
代替:
<input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>"/>
利用
//usual syntax
<?php echo $blog['email']; ?>
//short syntax
<?= $blog['email'] ?>
或使用Senad Meškin的解決方案為您的輸入框設置默認值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.