PHP redirect header

2013 年 11 月 15 日4090

If you really want to redirect to a new page, header('Location: <your new URL>') is about as simple as it gets. However, you could just write your PHP such that the same page does different things depending on if the user is found or not. This is especially useful if whatever database interaction you are doing is expensive, and you'd rather not repeat it more than necessary.

In addition, some other comments mentioned that you are vulnerable to SQL injection, because you are putting user-supplied data directly into your SQL without validating it in any way. Do not do this, unless you want to be hacked.

0 0