duandan5471 2014-04-28 03:42
浏览 47
已采纳

在登录表单上使用PHP来替换文本

I'm basically working on a Bootstrap website I've made. I connected my Forum (MyBB) so I could log in through my website.
The problem now is that since I'm still getting used to PHP, I'm stuck attempting to replace the Sign in text with the name of the user and also the Sign Up with Logout or Disconnect.

This is so far how it looks:

This is so far how it looks

And this is what i would like to achieve:

And this is what i would like to achieve

Also fetching the forum avatar and displaying it on the bar

This is my form:

<?php

    if($mybb->user['uid'])
    {
        // If the user if logged in, display a welcoming message.
        echo "<div class='welcome-msg'>Welcome back ".$mybb->user['username']."!<br /></div>";
        echo "<div class='warning'>Log out.";
    }
    else
    {
        // If the user is not logged in, display the login form.
        echo "<form action='forums/member.php' method='post'>";
        echo "<input type='hidden' name='action' value='do_login' />";
        echo "<input type='hidden' name='url' value='../index.php' />";
        echo "<input id='user_username' placeholder='Username' type='text' name='username' maxlength='30' /><br />";
        echo "<input id='user_password' placeholder='Password' type='password' name='password' /><br />";
        echo "<input class='btn btn-warning' style='clear: left; width: 100%; height: 32px; font-size: 13px;' type='submit' name='submit' value='Login' />";
        echo "</form>";
    }

?>

I'm not asking for someone to actually make it, obviously. I just need some reference about how I could achieve it. (Ex: Using what type of)

  • 写回答

1条回答 默认 最新

  • dongshuiga2826 2014-04-28 04:18
    关注

    You are using bootstrap so you would need to modify the code in your navbar/navigation section using the if($mybb->user['uid']) if the user is logged in just swap out the links, using an if/else schema. You would be able to pull whatever data for the database you need to display the forum image etc. If you are using these links in your header the same applies, just modify the area where you deal with Sign Up / Sign In.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分