重定向提交按钮(“登录"页面) [英] Redirect submit button (Login page)

查看:116
本文介绍了重定向提交按钮(“登录"页面)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题.我有一个带有提交"按钮的登录框,但是无法重定向到另一个页面.我插入了电子邮件和密码,但它不起作用,仅停留在第一页上.我该怎么办?

I have a little problem. I have a login box with a submit button, but I can't redirect to another page. I insert the email and password but it doesn't works, it just stay on the first page. What can I do?

我用这个:

header("Location: home.php");

这是我的代码:

<?php session_start();
    include_once 'dbconnect.php';
    if(isset($_SESSION['user'])!="") {
        header("Location: home.php");
    }
    if(isset($_POST['btn-login'])) {
    $email = mysql_real_escape_string($_POST['email']);
    $upass = mysql_real_escape_string($_POST['pass']);
    $res=mysql_query("SELECT * FROM users WHERE email='$email'");
    $row=mysql_fetch_array($res);
    if($row['password']==md5($upass)) {
        $_SESSION['user'] = $row['user_id'];
        header("Location: home.php");
    } else {
?>
<script>alert('wrong details');</script>
<?php } } ?> 

推荐答案

更改此

header("Location: home.php");

echo "<script>window.location.assign("home.php")</script>";

这篇关于重定向提交按钮(“登录"页面)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆