【发布时间】:2013-07-14 00:53:33
【问题描述】:
注意,在我的 store.php 里面我有 <?php include_once ("js.html"); ?>
我的目录映射和文件路径。
public
|_css
|_img
|_include
| |_ajax
| | |_username.php
| |_config.php
| |_js.html
|_items
|_js
|_slides
|_store.php
这是我在 js.html 中的代码
<script>
function ajax_username_check()
{
var check_this=$("#username").val();
$.post("include/ajax/username.php", {username : check_this}, function(email) {
//code here
})
}
</script>
这是我在 username.php 中的代码
<?php
require_once('../include/config.php');
$username = $_POST['username'];
$user = new user($pdo);
if(!$username == "")
{
$ok = $user->checkUsername($username);
if($ok == true)
{
echo '1';
}
else
{
echo '0';
}
}
?>
我似乎无法做到这一点
require_once('../include/config.php');
我试过../config.php,../include/config.php,include/config.php
当我的文件是这样的时候它起作用了:
public
|_css
|_img
|_include
| |_ajax
| |
| |_config.php
| |_js.html
|_username.php
|_items
|_js
|_slides
|_store.php
js.html
<script>
function ajax_username_check()
{
var check_this=$("#username").val();
$.post("username.php", {username : check_this}, function(email) {
//code here
})
}
</script>
用户名.php
<?php
require_once('include/config.php');
$username = $_POST['username'];
$user = new user($pdo);
if(!$username == "")
{
$ok = $user->checkUsername($username);
if($ok == true)
{
echo '1';
}
else
{
echo '0';
}
}
?>
我在重新组织我的文件夹时遇到了这个问题,我不知道这是否是一个简单的错误。任何帮助将不胜感激。谢谢!
【问题讨论】:
-
为什么不尝试完整的真实路径呢?例如:/home/www/...
-
我试过
if(@require_once('127.0.0.1/include/config.php')) { echo '0' } else { echo '1' },但它不起作用 -
include/config.php应该可以工作... -
刚试过,不行
-
ok,用最安全的方法,能发公众的完整路径吗?