在不同页面,特定div中回显登录错误 [英] echo login error in different page, specific div

查看:167
本文介绍了在不同页面,特定div中回显登录错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题延迟太久了。我有一个index.php,包括form和login.php handeling它。

Delayed too long with this issue. I have a index.php including form and login.php handeling it.

如何在index.php中的特定div中发布错误?
这是Index.php容器,idnex.php中还没有php代码。

How do I post the errors in a specific div in index.php? Here is the Index.php container, no php code in idnex.php yet.

    <div id="container">
    <section>
        <h1>ברוכים הבאים לאתר קופונים</h1>
        <h2>המקום בו תוכלו למצוא קופונים בסביבתכם</h2>
        <hr>
    </section>

    <section id="mainpage">
            <p class="welcome">
                אנא התחבר בכדי ליצור ולראות קופונים בקרבתך</br>
                <a href="php/register.php">הירשם לאתר</a> 
            </p>

            <form action="php/login.php" method="post" class="form">
                <p class="email">
                    <input type="text" name="email" /> :דואר אלקטרוני</br>
                </p>
                <p class="password">
                    <input type="password" name="password" /> :סיסמא</br>
                </p>
                <p class="submit">  
                    <input type="submit" value="היכנס" />  
                </p>  
            </form>
    </section>
</div>

这里是login.php错误报告部分

and here is the login.php error reporting section

            //check matching input
        if($email == $dbemail && $password = $dbpassword){
            $_SESSION['email'] = $dbemail;
            include('../index.php');
            header('members.php');

        }
        else{
            include('../index.php');
            echo "Incorrect Password<style text-align:center;/>";
        }
    }

} else
    include('../index.php');
    die('<p class="error">User does not exist</p>');
} else
    include('../index.php');
    die('Please enter a Email and password');

试过这个

include('../index.php');
    die('<p class="error">User does not exist</p>');

无法在提交按钮下专门定位它(使用保证金:0自动左,正确的更改)

can't manage to specifically position it under the Submit button (using margin: 0 auto so left and right changes)

感谢您给予的任何帮助

推荐答案

更改您的 login.php file:

} else {
   // error happened
   $error = '<p class="error">User does not exist</p>'
   include('../index.php');
   exit;
...

和你的index.php文件:

and your index.php file:

<form action="php/login.php" method="post" class="form">
<?php
if(isset($error)) echo $error;
?>
<p class="email">
   <input type="text" name="email" /> :דואר אלקטרוני</br>
...

这篇关于在不同页面,特定div中回显登录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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