我不知道这是否是重复的问题。 我想在不使用会话的情况下为登录表单编码。所以我在下面尝试了代码...
这是我的ajax电话
$('#flogin').submit(function(e){
e.preventDefault();
var email = $('#email').val();
var pass = $('#pass').val();
var login =
'email='+email+
'&pass='+pass;
$.ajax({
url : "data.php",
type : "post",
dataType : "json",
data : login,
success : function (disp){
console.log(disp);
var obj = disp;
if(obj==""){
alert("You entered wrong Email or Password...");
$('#flogin')[0].reset();
}
else {
location.href = "http://localhost/login/welcome.php";
}
}
})
})
ajax响应代码data.php
if (isset($_POST['email'])!="" && isset($_POST['pass'])!=""){
$email = $_POST['email'];
$pass = $_POST['pass'];
$sql = " SELECT * FROM flogin WHERE email='$email' and pass='$pass' ";
$result = mysqli_query($conn,$sql);
$response = array();
while ($menu = mysqli_fetch_assoc($result)){
$response [] = array(
'id' => $menu['id'],
'fname' => $menu['fname'],
'lname' => $menu['lname'],
'email' => $menu['email'],
'dob' => $menu['dob']
);
}
echo json_encode($response);
}
现在,我想将此数据发送(var obj = disp;)到'welcome.php'页面。但是我不知道如何将数据发送到该页面...
答案 0 :(得分:0)
<script type="text/javascript">
$('.ownerround').click(function()
{
var id=this.id;
$.ajax({
type: 'POST',
url: '<?php echo site_url();?>Registration',
data: 'id='+id,
success: function()
{
});
});
</script>
get id in model page:-
$data=array('user_type'=>$this->input->post('id'));
$this->db->insert('user',$data);