1

私の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';
        }
    }
?>

フォルダを再編成している間、私はこれに少し立ち往生していました。それが単純な間違いかどうかはわかりません。どんな助けでも大歓迎です。ありがとう!

4

1 に答える 1

0

これでうまくいくと思います:

require_once(dirname(__FILE__)  . '/../config.php');
于 2013-07-29T08:42:29.033 に答える