zoukankan      html  css  js  c++  java
  • php中的html元素

    我们先看下面的代码

    form2.php

    <html> 
    <head><title>greetins eartyling</title></head>
    <body> 
    <form action="formprocess2.php" method="post">
        <table>
            <tr>
                <td>Name</td>
                <td><input type="text" name="name" /></td>
            </tr>
            <tr>
                <td>Greetings</td>
                <td>
                    <select name="greeting" id="">
                        <option value="Hello">Hello</option>
                        <option value="Hola">Hola</option>
                        <option value="Bonjour">Bonjour</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td> </td>
                <td><input type="checkbox" name="debug" checked="checked"/>Display Debug info</td>
            </tr>
            <tr>
                <td colspan="2" style="text-align:center">
                    <input type="submit" name="submit" value="Submit"/>
                </td>
            </tr>
        </table>
    </form>
    </body>
    </html>

    formprocess2.php

    <html>
        <head>
            <title>Greeting earthing</title>
        </head>
        <body>
        <?php
        echo '<h1>'.$_POST["greeting"] ."  ".$_POST["name"].' !</h1>';
        if(isset($_POST["debug"]))
        {
            echo '<pre><strong>Degut:</strong>';
            print_r($_POST);
            echo '</pre>';
        }
        ?>
        </body>
    </html>

    选中Display Debug info这个checkbox然后点击submit显示内容如下:

    Bonjour 谁谁谁 !

    Degut:Array
    (
        [name] => 谁谁谁
        [greeting] => Bonjour
        [debug] => on
        [submit] => Submit
    )

    可以看到input元素的值都可以使用$_POST("name")函数来获得,不单单是文本框,单选框checkbox和下拉列表框select都可以,注意这里checkbox如果选中获取的值是"on",不是true,还有如果我们没有选中checkbox使用$_POST("debug")来获取这个checkbox的值会报错,因为$_POST这个数组中没有这个元素。

  • 相关阅读:
    ios9 键盘使uiwindow上移
    UIStackView在UITableviewCell中
    uitableviewcell侧滑删除等
    系统设置
    UIImagePickerController 导航样式调整
    设置frame时,大小在不同型号手机上不同
    storyBoard Reference 的坑
    uitableview 滚回顶部
    swift格式化输出
    UIAlertController
  • 原文地址:https://www.cnblogs.com/tylerdonet/p/3702577.html
Copyright © 2011-2022 走看看