dtpa98038 2017-07-08 12:58
浏览 91
已采纳

POST表单不与PHP一起使用,与Postman合作

This is login code with session. Iam using bootstrap.The code is not redirecting to index.html, when I test it in Postman it works but it is not working in this bootstrap template. I didnt get the reason? Please Help

<?php

if($_SERVER["REQUEST_METHOD"]=="POST") {
    $email=$_POST["email"];
    $password=$_POST["password"];

    $sql = "SELECT * FROM login where email='$email' and password='$password'";

    $result = mysqli_query($conn,$sql);
    $row=mysqli_fetch_array($result,MYSQLI_ASSOC);
    $count = mysqli_num_rows($result);

    if ($count>0) {

        // output data of each row
        if($row['admin_role']==1) {
            //$_SESSION["email"]=$email;
            //$_SESSION["id"]=$row['user_id'];

            //echo "Login successfull";

            header('Location: index.html');
            exit; 
        }
    } else {
        echo "0 results";
    }
}

?>


<div class="row">
    <div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-4">
        <div class="login-panel panel panel-default">
            <div class="panel-heading"> Admin Log in</div>
            <div class="panel-body">
                <form role="form">
                    <fieldset>
                        <div class="form-group">
                            <input class="form-control" placeholder="E-mail" name="email" type="email" autofocus="">
                        </div>
                        <div class="form-group">
                            <input class="form-control" placeholder="Password" name="password" type="password" value="">
                        </div>
                        <div class="checkbox">
                            <label>
                                <input name="remember" type="checkbox" value="Remember Me">Remember Me
                            </label>
                        </div>
                        <a href="" class="btn btn-primary">Login</a>
                    </fieldset>
                </form>
            </div>
        </div>
    </div><!-- /.col-->
</div><!-- /.row --> 
  • 写回答

4条回答 默认 最新

  • doujie2356 2017-07-08 13:01
    关注

    Your form is a GET form, you need to set method="POST" on your <form> tag.

    Other than that, your code is very vulnerable, you should be hashing the passwords in your database, and you should use PDO as it's more secure and you should also use prepared statements and turn off emulated ones with that.

    Currently, your code is vulnerable to SQL injection, one of the most basic but the most dangerous security threats for a web application.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了