이 좋아, 그래서 나는이 기능을 가지고PHP 함수가 jquery POST 데이터를 읽을 수 없습니까?
기능이 JQuery와 스크립트에 의해 액세스해야<?php
/**
* @author Mitchell A. Murphy
* @copyright 2011
*/
include ('func_lib.php');
connect();
echo (check($_POST['input']) ? 'true' : 'false');
function check($args)
{
$args = strtolower($args);
$checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
if (preg_match($checkemail, $args))
{
//logic for email argument
$sql = "SELECT * FROM `users` WHERE `email`='" . $args . "'";
$res = mysql_query($sql) or die(mysql_error());
echo "type=email:";
if (mysql_num_rows($res) > 0)
{
return true;
} else
{
return false;
}
} else
{
//logic for username argument
$sql = "SELECT * FROM `users` WHERE `username`='" . $args . "'";
$res = mysql_query($sql) or die(mysql_error());
echo "type=username:";
if (mysql_num_rows($res) > 0)
{
return true;
} else
{
return false;
}
}
}
?>
:
$('form.register .submit').click(validateRegister);
function validateRegister() {
//Variables
var emailExists = false;
var userExists = false;
var $error = "";
//Executes functions
email();
function email() {
var $error = $('#email .error');
var input = $('#email input').val();
var emailRE = /^.*@.+\..{2,5}$/;
if (input.match(emailRE)) {
$error
.html('<div>Proper Email Format: <span>[email protected]</span></div>')
.animate({
'left': '-130px',
'opacity': '0'
});
//Checks for Existing Email
function checkExisting_email() {
$.ajax({
type: 'POST',
url: 'includes/checkExist.php',
data: input,
statusCode: {
404: function() {
alert('page not found');
}
},
success: function (data) {
alert(data);
},
error: function() {
alert("error bro");
}
});
}
emailExists = checkExisting_email();
//If it exists
if (emailExists) {
alert("This email already exists!");
} else if (emailExists == false) {
alert("Email doesnt exist!");
}
} else {
//Email doesn't match
$error
.html('<div>Proper Email Format: <span>[email protected]</span></div>')
.animate({
'left': '-150px',
'opacity': '1'
});
}
}
return false;
}
그러나 스크립트 (JS)가 데이터를 전송하지 어떤 이유로
? 그렇다면 어떻게 참조해야합니까? 나는 백엔드 개발자이지만 자바 스크립트를 만든 디자이너가이 문제를 해결하기 위해 나를 남겨 두었습니다. 왜 NULL로 반환 JQuery와의 입력은 ...<form action="includes/checkExist.php" method="post">
<input type="text" name="input" />
<input type="submit" name="submit" />
</form>
그리고 그 작동 : 나는이 HTML 마크 업 데이터를 전송하기위한 테스트 양식을 만들었 기 때문에 PHP는 작동 알아?
감사합니다 :) 나는 조금 전에 그것을 얻었지만, 이것이 내가 도움이되었을 것입니다 : P –