Does anyone know why this doesn't work? any help would be appreciated.
This is the HTML
Enter Code:<br/><input type="text" name="code" id="code"/><br/>
<input type="button" id="confirm" value="Confirm" onClick="confirm()"/>
This is the PHP (basically gets the value of the user input and if it's equal to the variable a echo sucess)
$code = $_POST["code"];
$a = 105678;
if($code==$a){
echo "sucess";
} else {
echo "nosucces";
}
The JavaScript (simple ajax code to alert yay on PHP sucess or nay on no sucess)
function confirm () {
$.post(
"confirm.php",
{code:$(this).val() },
function(data) {
if(data=='sucess') {
alert("yay");
} else {
alert("nay");
}
}
);
}
basically on all occasions the ouput is nay on further debugging i tried an elseif statement on the javascript asking if data is equal to nosucces but it didn't even alert anything, meaning it's not getting the data from the php