首页 >  毕业设计知识  > 正文

php控制用户提交信息字体样式

 本例通过对用户提交的数据进行拼接处理,使得用户可以选择字体样式,当单击提交按钮同时,最终的样式字体会显示在页面上。
 
  1.实例过程
 
  在页面添加表单和显示区域结构,并使用css样式进行布局和定位。
 
  实现返回不同的样式结果,使用了switch多分支结构,html样式标签和字符串连接运算符"."
 
  这样在用户提交信息的同时,字符串内容也会被html字体样式标签包含在内,可实现不同的字体样式效果。
 
  2.实例代码
 
PHP
<!doctype html>
<html lang="en">
<head>
 
</head>
<div class="fot">提交样式修改字体信息</div>
<div>
    <form action="" method="post">
        <div>
            <input type="text" value="" name="txt">
            <br>
            <h3>请选择样式类型:</h3>
        </div>
        <div>
            加粗 <input type="radio" name="css" value="1" checked> &nbsp;
            倾斜 <input type="radio" name="css" value="2" > &nbsp;
            下划线 <input type="radio" name="css" value="3" > &nbsp;
        </div>
        <input type="submit" value="提交" name="sel">
    </form>
</div>
<div>
    <?php
        if(isset($_POST['sel'])){
            $type =$_POST['css'];
            switch ($type){
                case "1":
                    echo "<b>{$_POST['txt']}</b>";
                    break;
                case "2":
                    echo "<i>{$_POST['txt']}</i>";
                    break;
                case "3":
                    echo "<u>{$_POST['txt']}</u>";
                    break;
                default:
                    exit("参数有错!");
            }
        }
 
    ?>
</div>
<body>
 
</body>
</html>

以上是本题目部分介绍,若需要完整版或不符合您的要求,请联系客服QQ:242219979

上一篇:php检测用户输入日期的合法性

下一篇:计算机毕业设计选题不要怕,你想知道的这里都有!