将一个php页面链接到另一个php页面

时间:2018-08-26 07:37:49

标签: php html

我正在尝试使用不带数据库的php链接一个make登录页面,但是指向其他页面的链接不起作用。它停留在同一页面上。也没有错误消息。

这是代码的php部分:

private void getLocation(String lat, String longt) {
String myCity = " ";
Geocoder geocoder = new Geocoder(MainActivity.this, Locale.getDefault());
    try {
        List<Address>addresses = geocoder.getFromLocation(Double.parseDouble(lat),Double.parseDouble(longt), 1);
        String address = addresses.get(0).getAddressLine(0);
        myCity =  addresses.get(0).getLocality();
        Log.d("myLog", "Address: " + address);
        String arrp[] = address.split(",");
        Log.d("myLog", "City:  " + arrp[0]);

       }
catch (IOException e) {
        e.printStackTrace();
    }

我的html表单部分是:

<?php
    $error = "";

if(isset($_POST['MRDlogin']))
{
    if(isset($_POST['username'],$_POST['password'])){

        /*** You can change username & password ***/
        $user = array(
                        "user" => "MRD",
                        "pass"=>"msit"          
                );
        $username = $_POST['username'];
        $pass = $_POST['password'];
        if($username == $user['user'] && $pass == $user['pass']){

            header("Location: http://localhost/portal/MRD.php");
        }else{
            $error = '<div class="alert alert-danger">Invalid Login</div>';
        }
    }
}

2 个答案:

答案 0 :(得分:1)

找不到以下变量

$_POST['MRDlogin']

将其添加到您的按钮中,如下所示

 <div class="panel-body">
                 <?php echo $error; ?>
                 <form accept-charset="UTF-8" action="page.php" role="form" method="post">
                     <fieldset>
                         <div class="form-group">
                             <input class="form-control" placeholder="Username" name="username" type="text">
                         </div>
                         <div class="form-group">
                             <input class="form-control" placeholder="Password" name="password" type="password" value="">
                         </div>
                             <input class="btn btn-lg btn-success btn-block" type="submit" value="Login" name="MRDlogin">
                     </fieldset>
                 </form>

答案 1 :(得分:0)

在表单标签中添加具有页面名称值的操作标签,该标签将处理提交的表单:

<form action="page.php" accept-charset="UTF-8" role="form" method="post">