i am still having the same issue as before but this one is more specified and more info here’s my form:
<form method="post"action="">
<table>
<tr> <td>Login</td></tr>
<tr><td> <input name="LEmail" id="LEmail" value="Email"/></td>
<td> <label class="error" id="LEmail_error">*invalid</label></td>
</tr>
<tr>
<td><input name="LPassword" id="LPassword" value="Password"/></td>
<td><label class="error" id="LPassword_error">*invalid</label>
</td>
</tr>
</table>
<input type="button" class="LButton" id="LButton" value="submit"/>
</form>
and here is the jquery
$(document).ready(function(){
$('.error').hide();
$(".LButton").click(function(){
//alert("yay i was clicked");
var LEmail=$("input#LEmail").val()
if(LEmail==""||LEmail=="Email"){
$("label#LEmail_error").show();
return false;
}
var LPassword=$("input#LPassword").val();
if(LPassword==""||LPassword=="Password"){
$("label#LPassword_error").show();
return false;
}
var info='LEmail='+ LEmail + '&LPassword=' + LPassword;
alert(info);
$.ajax({
type:"POST",
url:"process.php",
//dataType: string;
data: info,
success:function(data){
window.location.href="process.php";
alert(data);
},
error: function(xhr, type, exception){
alert("something went wront here");
alert("Error: " + type);
console.log('@Error: '+errorThrown);
console.log('@Status: '+status);
console.log('@Status Text: '+xhr.statusText);
}
})
});
});
and the php
$LEmail=$_POST['LEmail'];
$LPassword=$_POST['LPassword'];
/*
if(mysql_num_rows(mysql_query("SELECT EmailAddress AND Password FROM Users WHERE EmailAddress= $LEmail AND Password=$LPassword)>0){
}
*/
var_dump($LEmail);
var_dump($LPassword);
for some reason when the php page loads it claims it is an undefined index LEMail same for LPassword
all my variables are NUM but when i do the alerts the values are correct
Use a url encode around the POST data values:
If your POST data is not properly encoded, the PHP script will not be able to parse it.
Edit
I think this is the problem
When this happens your process.php has already processed the ajax call. You’re calling it for a second time here, and obviously with a redirect like that there is no POST data and that is why you’re seeing
undefined indexerrors.