开发者

PHP redirecting problem

开发者 https://www.devze.com 2023-03-14 07:42 出处:网络
I have this login form which uses AJAX to query a database for checking if the user exist, if the password is correct, etc. Now, how can I re开发者_运维问答direct the user when all the checking is don

I have this login form which uses AJAX to query a database for checking if the user exist, if the password is correct, etc. Now, how can I re开发者_运维问答direct the user when all the checking is done? I have tried to just do like this:

//PHP code...
//A lot of different checks happens before this
if($_POST['password']==$db_password){ //Last check!
   header("Location: member-page.php");
}

But that doesn't work (it doesn't return any errors either):( So, how can I do this? Thanks for the help!


If you're doing it via AJAX you'll have to do it on the page that is making the AJAX request, so you'll need to do it client-side... in jQuery it might look a bit like this...

$.post("test.php", { name: "John", time: "2pm" },
 function(data) {
   if (jQuery.trim(data) == 'success') {
    window.location = '/member-page.php';
  }
 });
0

精彩评论

暂无评论...
验证码 换一张
取 消