zoukankan      html  css  js  c++  java
  • PHP与Web页面的交互

    1.form表单默认情况下提交数据的方式为get方式。

    2.PHP脚本用来处理表单数据的预定义变量是$_GET,$_POST(区分大小写)

    代码示例:(特别注意复选框属性name的时候加数组)

    simpleTest.html

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <form action="simpleForm.php" method="post">
        用户名:<input type="text" name="username"><br>
        密码:<input type="text" name="password"><br>
        <!-- 复选框 -->
         学过的编程语言是:<br>
        <input type="checkbox" name="language[]" value="PHP">php
        <input type="checkbox" name="language[]" value="java">java
        <input type="checkbox" name="language[]" value="C#">C#
        <input type="checkbox" name="language[]" value="C++">C++<br>
        <input type="submit" value="提交" >
    </form>
    </body>
    </html>

    simpleFoem.php

    <?php
    if(!empty($_POST["username"])){
        if($_POST["username"]=="zhangsan"&&$_POST["password"]=="123"){
            echo "欢迎您:".$_POST["username"]."<br/>";
            echo "学过的编程语言:";
            foreach ($_POST["language"] as $value){
                echo  $value;
                
            }
            
        }else {
            echo "用户名密码错误";
        }
    }
        
    ?>
  • 相关阅读:
    CentOS下设置ipmi
    CentOS 使用文件增加Swap空间
    CentOS LVM
    做IT需要掌握的电力基础知识
    CentOS 7搭建本地yum源
    Lsi卡和IB卡在CentOS中升级
    Mellanox 4036配置
    IdentityServer4入门二
    IdentityServer4入门一
    RAFT选举算法-分布式数据库困惑
  • 原文地址:https://www.cnblogs.com/sunxiaoyan/p/9258102.html
Copyright © 2011-2022 走看看