• PHP 提交自动验证的订单


    <!DOCTYPE HTML>
    <html>
    <body>
    <?php
    $data=" ";
    $name = $email= $website1 = $comment = $gener = " ";
    $nameerr = $emailerr = $gendererr = $websiteerr = " ";

    if($_SERVER["REQUEST_METHOD"]=="POST")
    {
    if(empty($_POST["name"])){
    $nameerr="must write";
    }
    else {
    $name = test($_POST["name"]);
    if(!preg_match("/^[a-zA-Z ]*$/",$name)) //是否只有字符和空格
    {
    $nameerr = "仅支持母和空格!";
    }

    }

    if(empty($_POST["email"])){
    $emailerr="must write";
    }
    else {
    $email = test($_POST["email"]);
    if(!preg_match("/([w-]+@[w-]+.[w-]+)/",$email)) //是否有@和.字符
    {
    $emailerr = "邮件格式不对!";
    }
    }

    $website1 = test($_POST["website"]);
    if (!preg_match("/(?:(?:https?|ftp)://|www.)[-a-z0-9+&@#/%?=~_|!:,.;]*[-a-z0-9+&@#/%=~_|]/i",$website1)) //www.baidu.com
    {
    $websiteerr = "网站的格式不对";
    }

    $comment = test($_POST["comment"]);

    if(empty($_POST["gender"])){
    $gendererr = "must write";
    }
    else {
    $gener = test($_POST["gender"]);
    }

    }

    function test($data)
    {
    $data = trim($data);//去掉多余的空格 换行
    $data = stripslashes($data);//去掉多余的 /
    $data = htmlspecialchars($data);//转化为html实体
    return $data;
    }
    ?>

    <h1>please input your informmation.....</h1>
    <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?> " method="post">
    Name: <input type="text" name="name" values="<?php echo $name ;?>"> <span class="error"> * <?php echo $nameerr ;?></span><br><br>
    E-mail: <input type="text" name="email" values="<?php echo $email ;?>"> <span class="error"> * <?php echo $emailerr ;?></span><br><br>
    Website: <input type="text" name="website" values="<?php echo $website ;?>"> <span class="error"> * <?php echo $websiteerr;?></span><br><br>
    comment: <textarea name="comment" rows="5" cols="40" values="<?php echo $comment;?>"> </textarea> <br>
    gener:<input type="radio" name="gender"
    <?php if (isset($gender) && $gender=="female") echo "checked";?>
    value="female"> Female

    <input type="radio" name="gender"
    <?php if (isset($gender) && $gender=="male") echo "checked";?>
    value="male">Male <span class="error"> * <?php echo $gendererr ;?></span> <br>

    <input type="submit" <?php echo "登陆" ?>> <br>
    </form>

    <?php
    echo "informmation:<br>";
    echo $name;
    /*echo "<br>";
    echo $email;
    echo "<br>";
    echo $website1;
    echo "<br>";
    echo $comment;
    echo "<br>";
    echo $gener;
    //<span class="error"> * </span>组合一些信息*/


    ?>
    </body>
    </html>

  • 相关阅读:
    tomcat shutdown后,进程还存在linux系统中的解决办法
    nginx反向代理tcp协议的80端口
    redis集群搭建中遇到的一些问题
    《将博客搬至CSDN》
    最短路路径(1.1版待更新)
    线段树
    SDUT 3341 数据结构实验之二叉树二:遍历二叉树
    二叉树的遍历
    爆头题HDU
    图的入度和出度以及图的新的存储形式
  • 原文地址:https://www.cnblogs.com/jiangger/p/6439766.html
Copyright © 2020-2023  润新知