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 pip install后修改模块路径,import失败,需要在哪里修改环境变量?
  • ¥15 爬取1-112页所有帖子的标题但是12页后要登录后才能 我使用selenium模拟登录 账号密码输入后 会报错 不知道怎么弄了
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题