duanji1482 2018-02-11 10:20
浏览 115

为什么显示“请输入用户名”而不是录制

I am writing a php file. It should read the username and password I enter and recored them to a txt file. It is only showing please enter username. It isn't showing my background colors either.

<!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>NewHW3</title>
    </head>

<body>
<style scoped>
body {font-family: Arial, Helvetica, sans-serif;}
form {border: 3px solid #f1f1f1;}

input[type=text], input[type=password] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    display: inline-block;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

button {
    background-color: #333FFF;
    color: white;
    padding: 14px 20px;
    margin: 8px 0;
    border: none;
    cursor: pointer;
    width: 100%;
}

button:hover {
    opacity: 0.8;
}

.cancelbtn {
    width: auto;
    padding: 10px 18px;
    background-color: #f44336;
}

.imgcontainer {
    text-align: center;
    margin: 24px 0 12px 0;
}




.container {
    padding: 16px;
}

span.psw {
    float: right;
    padding-top: 16px;
}

/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
    span.psw {
       display: block;
       float: none;
    }
    .cancelbtn {
       width: 100%;
    }
}
</style>



   
    <h1>User Login</h1>
        <form method="post" action="863l.php">
            Username: <input type="text" name="uname" placeholder="Username">
            Password: <input type="password" name="password" placeholder="Password">
            <input type="submit" name="login" value="Login">
        </form>
        
    </body>
</html>

That's the first code, it is supposed to display username and password. It seems to work but when I run it just says please enter username on the top.

<?php

$uname=$_POST['username'];
$password=$_POST['password'];
if ($uname==''){
    echo "<script>alert('Please Enter Username');</script>";
    exit();    
}
if (!isset($_POST['username'])) ;{
}
 if(!isset($_POST['password'])); 


$fp=fopen("863l.txt", "a"); 
$savestring="Username: ".$email."
"."Password: ".$password."
";
fwrite($fp, $savestring);
fclose($fp);
?>

The second code is supposed to record my input information into a txt file, it isn't doing that.

I didn't add the text file, bit it isnt recording to it either:

enter image description here

</div>
  • 写回答

1条回答 默认 最新

  • dongtao5104 2018-02-11 10:26
    关注

    change this:

    $uname=$_POST['username'];
    

    to this:

    $uname=$_POST['uname'];
    

    because your input form like this

     Username: <input type="text" name="uname" placeholder="Username">
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:未加密前两个软件都可以打开,加密后只有A软件可打开,B软件可以打开但读取不了数据
  • ¥15 在matlab中Application Compiler后的软件无法打开
  • ¥15 想问一下STM32创建工程模板时遇到得问题
  • ¥15 Fiddler抓包443
  • ¥20 Qt Quick Android 项目报错及显示问题
  • ¥15 而且都没有 OpenCVConfig.cmake文件我是不是需要安装opencv,如何解决?
  • ¥15 oracleBIEE analytics
  • ¥15 H.264选择性加密例程
  • ¥50 windows的SFTP服务器如何能批量同步用户信息?
  • ¥15 centos7.9升级python3.0的问题