脚本宝典收集整理的这篇文章主要介绍了php – 我的AJAX查询没有正确验证,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
if (isset($_POST['login'])) { $email = MysqLi_real_escaPE_string($con,$_POST['email']); $password = MysqLi_real_escape_string($con,$_POST['password']); $result = MysqLi_query($con,"SELECT * From users WHERE email = '" . $email. "' and password = '" . md5($password) . "'"); if ($row = MysqLi_fetch_array($result)) { echo json_encode('true'); $_SESSION['usr_id'] = $row['id']; $_SESSION['usr_name'] = $row['name']; $_SESSION['LOGged_in'] = true; } else { echo json_encode('false'); $errormsg = "Incorrect Email or Password!!!"; } } ?>
$(document).ready(function() { $('#login_submIT').click(function() { VAR form = $('#login_form').serialize(); $.ajax({ type: "POST",url: "header.PHP",data: form,success:function (response){ alert('Hi'); },error: function(response){ alert('Nope'); } }); }); });
<form id="login_form" form role="form" action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform"> <label class="login_form_labels"> Email:</label> <input type="email" id="email" class="login_input" name="email"><br><br> <label class="login_form_labels"> Password:</label> <input type="password" id="password" class="login_input" name="password"><br> <div id="stay_log"> Stay logged in. <input type="checkBox" name="stayLoggedIn" value=1 id="checkBox_1"> </div> <input class="login_form_BTn" name="login" value="Submit" type="Submit" id="login_submit"> <button class="login_form_btn" type="button">Forget your Password?</button> </form>
请帮忙!
$.ajax({ type: "POST",dataType: json,success:function (response){ alert('Hi'); },error: function(response){ alert('Nope'); } });
试试这个…
以上是脚本宝典为你收集整理的php – 我的AJAX查询没有正确验证全部内容,希望文章能够帮你解决php – 我的AJAX查询没有正确验证所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。