【发布时间】:2011-12-08 21:15:35
【问题描述】:
我是 PHP 新手,无法理解数据是如何从表单传递到数据库的。
我的表单:
<select name="parentgallery" id="parentgallery">
<option value="0" ><?php _e('Choose gallery', 'nggallery') ?></option>
<?php
foreach($this->gallerylist as $gallery) {
//special case : we check if a user has this cap, then we override the second cap check
if ( !current_user_can( 'NextGEN Upload in all galleries' ) )
if ( !nggAdmin::can_manage_this_gallery($gallery->author) )
continue;
$name = ( empty($gallery->title) ) ? $gallery->name : $gallery->title;
echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . $name . '</option>' . "\n";
} ?>
</select>
我制作的这个select 与一个工作的GalleryTitle var 并排在同一页面上传递给这个函数。所以我猜这是将数据传递到数据库的好地方:
if ($_POST['addgallery']){
check_admin_referer('ngg_addgallery');
if ( !nggGallery::current_user_can( 'NextGEN Add new gallery' ))
wp_die(__('Cheatin’ uh?'));
$newgallery = esc_attr( $_POST['galleryname']);
if ( !empty($newgallery) )
nggAdmin::create_gallery($newgallery, $defaultpath);
}
PHP 的问题(与我习惯使用的 Rails 不同)是我看不到这些数据传递到数据库的生命线。我只能猜测传递了什么以及如何接收。
问题:
如何将我的parentgallery 值与galleryname 变量一起发布到数据库?
【问题讨论】:
标签: php forms wordpress plugins customization