jquery - php header forwarding issue using Ajax -
form:-
<form name="form"> <div class="formfieldcontainer"> <label> email :</label> <div class="login_wrapper logincontainer"> <span> </span> <input type="email" id="email" required name="user_email" autofocus="autofocus" placeholder="enter email address"/> </div> </div> <div class="formfieldcontainer"> <label> password :</label> <input type="password" name="user_password" placeholder="enter password"/> </div> <input type="button" name= "submit" value="submit" id="submit_login"/> </form>
ajax:-
$("#submit_login").click(function(){ var username=$('input[name=user_email]').val(); var password=$('input[name=user_password]').val(); $.ajax({ type: "post", url: "newexam.php", data:{name: username, pwd: password}, cache: false, success: function(dataa) { if(dataa) { console.log(dataa); if(dataa==0) { $('form').effect( "shake" ); $('p.error').show(); $("#submit_login").val('login') alert('nodata'); } else if(dataa==1){ window.location.href="user.php"; } } } });// ajax });
php:-
<?php include('db.php'); $email_php = $_post['name']; $pwd_php=$_post['pwd']; $sql = "select name user email='$email_php' , password='$pwd_php'"; $result = mysqli_query($conn,$sql); $num_rows= mysqli_num_rows($result); if($num_rows>0){ $_session['login_user']= $email_php; echo '1'; } else{ echo '0'; } ?>
i need page redirect user.php when logged in successfully. getting following error:
notice: undefined index: name in c:\xampp\htdocs\demo\newexam.php on line 3 notice: undefined index: pwd in c:\xampp\htdocs\demo\newexam.php on line 4
how overcome it?
yo should redirecting php page (using headers)instead of using window.location.href
Comments
Post a Comment