dongyiyu3953 2014-09-01 16:18
浏览 57

如何从目标文件夹中访问我的用户登录脚本的代码

I'm new for php mysql. I need help for developing my website. Actually, I'm using a open source loin script. and i put each file of this script in cpuser folder. But my website files are located in main root of web address. you can access my website by going to http://hdsweb.co.in/. and my user script can by accessed from http://hdsweb.co.in/cpuser/

in my script documentation a code was given to secure external pages and that was

  <?php
   include 'dbc.php';
   page_protect();
  ?>

  // place html or other php code below this.

But when i add this code in index file located outside cpuser folder. then i get this error.

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/hdswebco/public_html/index.php:3) in /home/hdswebco/public_html/cpuser/dbc.php on line 64

Warning: Cannot modify header information - headers already sent by (output started at /home/hdswebco/public_html/index.php:3) in /home/hdswebco/public_html/cpuser/dbc.php on line 113 .

So please help me how to add these code in a simple php based html template.

my page format is something like this

      <!--Code to make script working-->

      <?php
      include 'cpuser/dbc.php';
      page_protect();
      ?>

     <!--Code ends-->

  <html>
  <head>
  <title>Welcome to HDS Web | Now Find out the latest web techniques with us.</title>
  </head>
  <body>
  <h1 align="left">HDS Web</h1>

 <p align="right">
  <?
  if (isset($_SESSION['user_id'])) {?>
  <div class="myaccount">
  <p><strong>My Account</strong></p>
  <a href="myaccount.php">My Account</a><br>
  <a href="mysettings.php">Settings</a><br>
  <a href="cpuser/logout.php">Logout </a>
  </div>

  <?
  else {
 // didn't login, show login link
  echo '<p><a href="login.php">Login</a></p>';

 } ?>



  </body>
  </html>
 <? } ?>

And i want to show different my account menu for logged in users and for new user only a login link.. Thats why i tried to use a if and else feature but else feature is not inserted well.. SO please resolve all these problems...

  • 写回答

2条回答 默认 最新

  • douguluan5102 2014-09-01 16:23
    关注

    To go up a level in linking to a file, use this.

    ../
    

    as in

    include '../dbc.php';
    

    To get back to the root directory, the highest level you can go, use this.

    /
    

    as in

    include '/dbc.php';
    

    Hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”