php传统表单上传数据

php传统表单上传数据的缺点很明显,就是当提交数据的时候,整个页面都会刷新。不仅浪费服务器带宽还会丢失原有的输入数据。

效果如图:
客户端提交数据:php传统表单上传数据_第1张图片
服务器接收并处理数据:
php传统表单上传数据_第2张图片

简单的表单数据提交实例:
表单提交数据.html代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表单提交数据</title>
</head>
<body>
    <div style="width:300px;height: auto;position: relative;margin:10px auto;">
        <h2>表单提交数据</h2>
        <form action="proccess.php" method="post">
            <label>用户名:<input type="text" name="username" /></label><br /><br />
            <label>密&nbsp;&nbsp;码:<input type="password" name="passw" /></label><br /><br />
            <label>邮&nbsp;&nbsp;箱:<input type="text" name="email" /></label><br /><br />
            <input type="submit" value="注册" style="position: absolute;right: 70px;" />
        </form>
    </div>
</body>
</html>

proccess.php代码:

<?php //接收提交的数据 $username = $_POST['username']; $passw = $_POST['passw']; $email = $_POST['email']; //输出测试,看是否收到数据 echo "用户名:".$username."<br />"; echo "密 码:".$passw."<br />"; echo "邮 箱:".$email."<br />"; ?>

你可能感兴趣的:(PHP,数据,表单,服务器,上传)