Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 账户编号为';t正在用PHP创建_Javascript_Php_Html - Fatal编程技术网

Javascript 账户编号为';t正在用PHP创建

Javascript 账户编号为';t正在用PHP创建,javascript,php,html,Javascript,Php,Html,我遇到的问题是,当我尝试创建帐户时,我得到的数据似乎总是 用户名必须介于3到15个字符之间 并且从未创建帐户。 另一件让我困惑的事情是页面被重新加载到login.html Create.html表单 <form action="create.php" method="post" id="createForm"> <div> <div class="row"> <div class="12u">

我遇到的问题是,当我尝试创建帐户时,我得到的数据似乎总是

用户名必须介于3到15个字符之间

并且从未创建帐户。

另一件让我困惑的事情是页面被重新加载到login.html

Create.html表单

<form action="create.php" method="post" id="createForm">
    <div>
        <div class="row">
            <div class="12u">
                <input type="text" name="Username" placeholder="Username" id="username"/>
            </div>
        </div>
        <div class="row">
            <div class="12u">
                <input type="password" name="Password" placeholder="Password" id="password"/>
            </div>
        </div>
        <strong id="strongText" style="display: none;"></strong>
        <div class="row">
            <div class="3u">
                <input type="button" value="Create Account" id="create"/>
            </div>
            <div class ="6u"></div>
            <div class="3u">
                <input type="button" value="Have an account?" id="login"/>
            </div>
        </div>
    </div>
</form>


Create.html javascript

$(文档).ready(函数(){
$(“#创建”)。单击(函数(e){
e、 预防默认值();
document.getElementById(“创建”).disabled=true;
document.getElementById('strongText').innerHTML=“正在创建帐户,请稍候…”;
$(“#strongText”).fadeIn();
var username=$('#username').val();
var password=$('#password').val();
$.ajax({
键入:“POST”,
数据:{
用户名:用户名,
密码:密码
},
url:'createCheck.php',
成功:函数(data){//从php代码接收数据
//控制台日志(数据);
如果(数据==“不可用”){
document.getElementById('strongText').innerHTML=“用户名不可用
”; document.getElementById(“创建”).disabled=false; }else if(数据=='用户名必须在3到15个字符之间'){ document.getElementById('strongText')。innerHTML=data+“
”; document.getElementById(“创建”).disabled=false; }else if(数据=='密码必须在5到25个字符之间'){ document.getElementById('strongText')。innerHTML=data+“
”; document.getElementById(“创建”).disabled=false; }否则{ 美元邮政( “create.php”, $('#createform')。序列化(), 功能(数据、状态){ document.getElementById('strongText')。innerHTML=data+“
”; window.location.href=“login.html”; } ); //window.location.href=“/login.php”; } }, 错误:函数(xhr,err){ console.log(“readyState:+xhr.readyState+”\n状态:+xhr.status); log(“responseText:+xhr.responseText”); } }); });
});所需的变量区分大小写,因此我需要从

<input type="text" name="Username" placeholder="Username" id="username"/>



我收到一个错误,该错误表示值为Null

其中是
会话_start()?您是否先测试了web服务。检查数据。trim()=“用户名必须在3到15个字符之间”@Gil我不确定您的意思是什么?@saty我从我的旧网站复制了此代码,所以我没有做任何更改
<input type="text" name="username" placeholder="Username" id="username"/>