jquery to php same issue but specified -


i still having same issue before 1 more specified , more info here's 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 jquery

$(document).ready(function(){     $('.error').hide();      $(".lbutton").click(function(){         //alert("yay 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 php

   $lemail=$_post['lemail'];      $lpassword=$_post['lpassword'];     /*     if(mysql_num_rows(mysql_query("select emailaddress , password users emailaddress=  $lemail , password=$lpassword)>0){     }     */      var_dump($lemail);     var_dump($lpassword); 

for reason when php page loads claims undefined index lemail same lpassword

all variables num when alerts values correct

use url encode around post data values:

var info='lemail='+ encodeuricomponent(lemail) + '&lpassword=' + encodeuricomponent(lpassword); 

if post data not encoded, php script not able parse it.

edit

i think problem

        success:function(data){             window.location.href="process.php";             alert(data);         }, 

when happens process.php has processed ajax call. you're calling second time here, , redirect there no post data , why you're seeing undefined index errors.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -