dongmeijian1716 2014-07-08 13:56
浏览 25
已采纳

HTML中的PHP代码

here $check variable is from php code..which is bolean... Actually if users put correct username and password this variables becomes true.. if this variable is true then i want replace the "Login" with "My account".. how can i do that? any help would be appreciated. Thanks.

if ($check) {
  <a href="myaccount.php" class="almanac">
    <svg viewBox="0 0 100 25" class="shape-tab">
      <use xlink:href="#shape-tab"></use>
    </svg>
    <span>My Account</span>
  </a>
} else {
  <a href="login.php" class="almanac">
    <svg viewBox="0 0 100 25" class="shape-tab">
      <use xlink:href="#shape-tab"></use>
    </svg>
    <span>Login</span>
  </a>
}

But problem is that $check is defined in php code.

  • 写回答

1条回答 默认 最新

  • dpj997991 2014-07-08 13:58
    关注

    You need to distinct the PHP and the HTML parts. This should do the trick:

      <?php if ($check) { ?>
      <a href="myaccount.php" class="almanac">
      <svg viewBox="0 0 100 25" class="shape-tab">
      <use xlink:href="#shape-tab"></use>
      </svg>
      <span>My Account</span>
      </a>
      <?php } else{ ?>
      <a href="login.php" class="almanac">
      <svg viewBox="0 0 100 25" class="shape-tab">
      <use xlink:href="#shape-tab"></use>
      </svg>
      <span>Login</span>
      </a>
      <?php } ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo