dream5694 2012-08-24 16:03
浏览 38
已采纳

在不同页面,特定div中回显登录错误

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

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>

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');

tried this

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

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

Thanks for any help given

  • 写回答

2条回答 默认 最新

  • donglei1973 2012-08-24 16:08
    关注

    change your login.php file:

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

    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>
    ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里