doulianqi3870 2013-05-01 20:48
浏览 44

如何通过有效的用户名和密码访问直接受限页面?

I am new in php coding. I just want to access a restricted index.php page through login username and password.

My folder/file listing are...

root-index.php
root/admin/index.php

I want to access ../admin/index.php from site root/index.php through valid username and password but if I want to access ../admin/index.php through browser addressbar, it will not be accessed or show message "Direct access is denied" or show error page (404).

I have tried putting .htaccess file inside the admin folder. but I failed to get the ../admin/index.php and it is showing error page.

my .htaccess file contains...

Order deny,allow
Require valid-user

I tried like joomla restriction in root/admin/index.php

//// No direct access.
defined('_JEXEC') or die;

but I really don't know how to bypass the above coding so the page is dying.

Can anybody help me on this matter ?

for your kind information, I am using Dreamweaver cs5 for coding and designing.

  • 写回答

1条回答 默认 最新

  • dongxikuo5171 2013-05-03 10:07
    关注

    From what I can gather from your question, you want a 'login' link on your sites landing page for admins, which they go to and log in using their credentials, and then gain access to your admin/index.php page?

    You really should just google search for a simple PHP login system (see here)

    But the basic ebb and flow of what you want, is on your admin index, look for $_SESION['user_session_id'], then redirect to a login.php if it's not set, get the user to log in using a form, check their credentials (please encrypt the password!) against the database, and if correct create the session and send them off to the admin/index.php page. If it's not correct, send them back to the login form, telling them that the credentials were wrong.

    I'm not sure exactly what you were asking as it's not incredibly clear, but that's the basis of what I surmised from your question and should be enough to get you started.

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思