php第一例

参考

例子 https://www.cnblogs.com/chinajins/p/5622342.html

配置多个网站 https://blog.csdn.net/win7system/article/details/52229796

实践

LAMPP安装后服务器的默认根目录为:

  • /opt/lampp/htdocs localhost对应的目录

在htdocs目录下创建test/login 目录,建立快捷方式

ln -s ~/code/PHP/login/ /opt/lampp/htdocs/test/login

login目录下:

login.html success.php

login.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <form action="success.php" method="post">
        用户名:<input type="text" name="username"><br/><br/>
        密码:<input type="password" name="pwd"><br/><br/>
        <input type="submit" name="submit" value="提交">
    </form>
</body>
</html>

sucess.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <?php
        $name = $_POST["username"];
        $pwd = $_POST["pwd"];
        $fp = fopen("./data.txt", "a");
        $str = "user:".$name."&password:".$pwd."\r\n";
        fwrite($fp,$str);
        fclose($fp);
        echo "<h1>欢迎回来,".$name."!</h1>";
    ?>
</body>
</html>

测试: http://localhost/test/login/login.html

posted @ 2018-08-28 15:17  疾风剑  阅读(103)  评论(0编辑  收藏  举报