在同一 PHP 页面中编辑用户的首选项


Editing user's preferences in the same PHP page

我有一个页面主页.php。在此页面中,我在左侧添加了一列,该列使用 include_once() 函数从文件配置文件.php添加用户的通用配置文件。

是这样的:

<div class='userprofile'>
    <?php 
        include_once('profile.php')
    ?>
</div>

现在我想通过使用"editprofile.php"之类的页面来编辑此配置文件。

用户应该单击其个人资料顶部可见的"EditProfile"按钮,然后在同一页面上(无需重定向),他可以编辑他的个人资料。

如何实现?

你可以使用 Jquery for this

 <div class='userprofile'>
  <?php 
    include_once('profile.php')
  ?>
 </div>
 <div class='editprofile'>
   <?php 
    include_once('editprofile.php')
   ?>
 </div>

默认情况下,赋予编辑配置文件类显示无属性

  .editprofile
   {
    Display:none;
   }

当用户使用 Jquery 单击"编辑配置文件"按钮时,隐藏 Div 宽度类"用户配置文件"并显示带有类"编辑配置文件"的div

    $('userprofile').css('Display','None');
    $('editprofile').css('Display','block');

    $('editprofile').css('Display','inline-block');

无论您想要哪个属性,都可以使用它

注意:我正在使用css属性来隐藏潜水,您也可以使用简单的隐藏和显示功能。

如果您不擅长jquery,请告诉我是否需要完整的代码