dtsnx44260 2015-09-05 17:04
浏览 31

php网页密码空验证

I wanted to check if the username and password fields are empty. If they are empty it should give a error message box and the message box should contain a message and a ok button. When user clicks the ok button the msg box should close and user should see the login page.

For that i wrote the below code. but after pressing the ok button on error message box the web page address is remaining same but the content is not getting displayed , full white page is displayed.

you do refresh and page comes back.

This is the file i am opening in browser register.php

<?php

// configuration
require("../includes/config.php");

// if user reached page via GET (as by clicking a link or via redirect)
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
    // else render form
    render("register_form.php", ["title" => "Register"]);
}

// else if user reached page via POST (as by submitting a form via POST)
else if ($_SERVER["REQUEST_METHOD"] == "POST")
{
    // TODO
    if (empty($_POST["username"]) || empty($_POST["password"]))
    {
        $message = "Username and/or Password empty.\
Try again.";
        echo "<script type='text/javascript'>alert('$message');</script>";
    }   
}
?>

And this is the form file register_form.php

<form action="register.php" method="post">
<fieldset>
    <div class="form-group">
        <label>Username :</label>
        <input autofocus class="form-control" name="username" placeholder="Username" type="text"/>
    </div>
    <div class="form-group">
         <label>Password :</label>
        <input class="form-control" name="password" placeholder="Password" type="password"/>
    </div>
    <div class="form-group">
         <label>Password :</label>
        <input class="form-control" name="confirmation" placeholder="Retype-Password" type="password"/>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-default">Register</button>
    </div>
</fieldset>
</form>

i want to see login page after clicking the ok button on the message box i do not want to see white page. please help

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么