使用HTML和CSS和PHP实现一个简单的简历制作项目

掌握HTML表单作用,以及action和method属性;

掌握HTML输入域作用、类型、标签,以及name和value属性;

掌握$_REQUEST变量的作用、语法和使用;

掌握注释,以及变量的作用、命名、赋值和输出;

掌握PHP+HTML混合编程。

  1. 使用HTML表单设计和实现下图简历;
  2. 使用PHP实现简历数据验证功能,包括输出简历信息,验证姓名(非空)、手机长度,验证年龄(18-60岁)范围等;
  3. 尝试用中文显示性别、学历、校名和专业,以及显示技能和爱好多选项。

效果图:

首页:

简历制作页面:

首页代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简历制作</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
    <div class="box">
        <h1>简历制作</h1>
        <form action="page2.php">
            姓 &nbsp; &nbsp; 名:<input type="text" name="username"  class="common" placeholder="请输入姓名"><br><br>
            性 &nbsp; &nbsp; 别:<label><input type="radio" name="sex" id="" value="male" checked>男</label>
                 <label><input type="radio" name="sex" id="gender" value="female">女</label><br><br>
            年 &nbsp; &nbsp; 龄:<input type="number" name="age" id="" class="common" placeholder="请输入年龄(18-60)"><br><br>
            电 &nbsp; &nbsp; 话: &nbsp;<input type="text" name="phonenum" class="common" placeholder="请输入电话"><br><br>
            邮 &nbsp; &nbsp; 箱: &nbsp;<input type="email" name="email" class="common" placeholder="必须@"><br><br>
            联系地址:&nbsp;<input type="text" name="address" class="common" placeholder="请输入联系地址"><br><br>
            邮 &nbsp; &nbsp; 编: &nbsp;<input type="text" name="postcode" class="common" placeholder="请输入邮编"><br><br>
            学 &nbsp; &nbsp; 历:<label class="pl"><input type="radio" name="degree" id="" value="junior" checked>大专</label>
                                 <label class="pl"><input type="radio" name="degree" id="" value="undergraduate">本科</label>
                                 <label class="pl"><input type="radio" name="degree" id="" value="master">硕士</label>
                                 <label class="pl"><input type="radio" name="degree" id="" value="doctor">博士</label><br><br>
            毕业院校:&nbsp;
                <select name="school">
                    <option value="hncst">海软</option>
                    <option value="hnrd">海热</option>
                    <option value="bd">北京大学</option>
                    <option value="qh">清华大学</option>
                    <option value="zkd">中国科学技术大学</option>
                    <option value="hd">海南大学</option>
                </select>
                <br><br>
                专 &nbsp; &nbsp; 业: &nbsp;&nbsp;
                <select name="profession">
                    <option value="software">软件</option>
                    <option value="kj">会计</option>
                    <option value="dm">动漫</option>
                    <option value="wd">舞蹈</option>
                    <option value="jd">机电</option>
                </select>
                <br><br>
                技&nbsp;&nbsp;&nbsp; &nbsp;能:
                <label id="jn"><input type="checkbox" name="skill[]" value="driver" checked id="">开车</label>
                <label id="jn"><input type="checkbox" name="skill[]" value="cook" id="">做菜</label>
                <label id="jn"><input type="checkbox" name="skill[]" value="pinao" id="">弹琴</label>
                <br><br>
                爱&nbsp;&nbsp;&nbsp; &nbsp;好:
                <label id="jn"><input type="checkbox" name="love[]" value="dance" checked id="">跳舞</label>
                <label id="jn"><input type="checkbox" name="love[]" value="sing" id="">唱歌</label>
                <label id="jn"><input type="checkbox" name="love[]" value="chess" id="">下棋</label>
                <label id="jn"><input type="checkbox" name="love[]" value="ball" id="">踢球</label>
                <br><br>
                自我介绍:<br>
                <textarea  name="introduce" cols="55" rows="8" placeholder="请在此输入工作经历等内容...."></textarea><br>
                <input type="reset" value="清空" class="btn1">
                <input type="submit" value="下一步" class="btn2">
        </form>
    </div>
</body>
</html>

首页CSS

*{
    margin: 0;
    overflow: 0;
    box-sizing: border-box;
}

body {
    background-color: #252525;
    background: url(./images/OIP-C.jpg) no-repeat;
    background-size: cover;
    background-attachment: fixed;
}

.box {
    width: 500px;
    /* height: 600px; */
    margin: 50px auto;
    border-radius: 15px;
    background-color: rgba(179, 197, 197,0.7);
    box-shadow: 5px 5px 1px 1px  rgb(178, 226, 244);
}

.box h1 {
    padding-top: 5px;
    font-weight: 400;
    text-align: center;
}

.box form {
    padding-top: 20px;
    padding-left: 25px;
}

.common {
    width: 300px;
    height: 30px;
    border-radius: 5px;
    border: #333;
    padding-left: 10px;
}

#gender , #jn{
    margin-left: 15px;
}

.pl {
    padding-left: 20px;
}
select {
    width: 200px;
    height: 25px;
    border-radius: 5px;
    font-size: 15px;
    background-color: #ececec;
}

textarea {
    margin-top: 10px;
}

.btn1,.btn2 {
    width: 200px;
    height: 40px;
    border-radius: 9px;
    border:0 solid #000;
    margin-top: 5px;
    margin-bottom: 15px;
}

.btn2 {
    margin-left: 15px;
}
.btn1:hover,.btn2:hover{
    font-size: 20px;
    cursor: pointer;
    background-color: antiquewhite;
}

简历制作页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdn.staticfile.net/font-awesome/4.7.0/css/font-awesome.css">
    <title>Document</title>
    <style>
        body{
            background-color: slategray;
        }
        /* 表格 字体颜色 */
        table{
            color: rgb(226, 222, 222);
        }

        .coverage{
            width: 80%;
            margin: 0 auto;
            /* border: 5px solid white; */
            height: 700px;
        }
        /* 插入的图片 */
        .head img{
            width: 300px;
            margin: 0 10px;
        }
        /* 头部左边 照片浮动*/
        .head_left{
            float: left;
            /* margin-top: -12px; */
        }
        /* 头部右边 基本资料 */
        .head_right{
            /* float: right; */
            margin-left: 350px;
        }
        /* 标题 */
        h3{
            width: 136px;
            background-color: rgb(235, 226, 226);
            padding: 0 10px;
            font-size: 25px;
            border-radius: 10px;
            margin: 20px 0px;
        }
        /* 表格中的单元格 */
        table td{
            font-size: 18px;
            /* border: 1px solid white; */
            padding: 6px 0;
        }
        /* 将基本资料中的单元格分为左右两部分 */
        /* 左部分单元格  即姓名性别之类*/
        .tr_left{
            width: 100px;
            text-align: center;
        }
        /* 右部分单元格 即年龄的输出内容*/
        .tr_right{
            width: 280px;
            padding-left: 20px;
        }
        /* 中间盒子*/
        .main{
            padding: 0 10px;
        }
        /* 中间盒子输出内容 */
        .cover{
            /* background-color: white; */
            width: 96%;
            height:50px;
            border-radius: 10px;
            margin-left: 4%;
            font-size: 18px;
            color: rgb(226, 222, 222);
        }
        /* 自我评价输出内容 主要是自我评价内容多,高度多调了一下 */
        .cover_bottom{
            /* background-color: white; */
            width: 96%;
            height:80px;
            border-radius: 10px;
            margin-left: 4%;
            font-size: 18px;
            color: rgb(226, 222, 222);
        }
        /* 底部内容 */
        .bottom{
            margin-top: 3px;
            text-align: center;
            color: rgb(226, 222, 222);
            background-color: #7b8195;
        }
    </style>
</head>
<body>
<?php
    //获取姓名
    $username=$_REQUEST["username"];
    //获取性别
    $sex=$_REQUEST["sex"];
    //获取年龄
    $age=$_REQUEST["age"];
    //获取手机号
    $tel=$_REQUEST["phonenum"];
    //获取邮箱
    $email=$_REQUEST["email"];
    //获取邮编 
    $postcode=$_REQUEST["postcode"];
    //获取地址
    $address=$_REQUEST["address"];
    //获取学校
    $school = $_REQUEST['school'];
    //获取专业
    $profession=$_REQUEST['profession'];
    //获取学历
    $degree=$_REQUEST['degree'];
    //获取技能
    $skill=$_REQUEST['skill'];
    //获取爱好
    $love = $_REQUEST['love'];
    //获取自我介绍
    $introduce = $_REQUEST['introduce'];
    ?>
    <div class="coverage">
        <div class="head">
            <div class="head_left">
                <img src="./images/1.jpg" alt="">
            </div>
            <div class="head_right">
                <h3><i class="fa fa-hand-o-right" style="font-size:36px"></i>基本资料</h3>
                <table>
                    <tr>
                        <td class="tr_left">姓&nbsp;&nbsp;&nbsp;名:</td>
                        <td class="tr_right">
                            <?php
                            //判空
                            if (isset($username)) {
                                echo $username;
                              } else {
                                echo '未输入姓名';
                              }
                            ?>
                        </td>
                        <td class="tr_left">专&nbsp;&nbsp;&nbsp;业:</td>
                        <td class="tr_right">
                            <?php
                                switch($profession){
                                    case "software":
                                        echo "软件";
                                        break;
                                    case "kj":
                                        echo "会计";
                                        break;
                                    case "dm":
                                        echo "动漫";
                                        break;
                                    case "wd":
                                        echo "舞蹈";
                                        break;
                                    case "jd":
                                        echo "机电";
                                        break;
                                }
                            ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="tr_left">性&nbsp;&nbsp;&nbsp;别:</td>
                        <td class="tr_right">
                            <?php
                                if($sex=='male'){
                                    echo "男";
                                }else {
                                    echo '女';
                                }
                            ?>
                        </td>
                        <td class="tr_left">学&nbsp;&nbsp;&nbsp;历:</td>
                        <td class="tr_right">
                            <?php
                                switch($degree){
                                    case "junior":
                                        echo "大专";
                                        break;
                                    case "undergraduate":
                                        echo "本科";
                                        break;
                                    case "master":
                                        echo "硕士";
                                        break;
                                    case "doctor":
                                        echo "博士";
                                        break;
                                }
                            ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="tr_left">年&nbsp;&nbsp;&nbsp;龄:</td>
                        <td class="tr_right">
                        <?php
                            function val_age($input,$min,$max){
                                $age=(int)$input;
                                return $age>=$min && $age<=$max;
                            }
                            $min=18;
                            $max=60;
                            if(val_age($age,$min,$max)){
                                echo $age;
                            }else{
                                echo  "超出范围";
                            }
                        ?>
                        </td>
                        <td class="tr_left">邮&nbsp;&nbsp;&nbsp;编:</td>
                        <td class="tr_right">
                            <?php
                                function val_post($postcode){
                                    return preg_match('/^\d{6}$/', $postcode);
                                }
                                if(val_post($postcode)){
                                    echo  $postcode;
                                }else{
                                    echo"无效邮编";
                                }    
                            ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="tr_left">邮&nbsp;&nbsp;&nbsp;箱:</td>
                        <td class="tr_right">
                            <?php
                                echo $email;
                            ?>
                        </td>
                        <td class="tr_left">联&nbsp;系&nbsp;电&nbsp;话:</td>
                        <td class="tr_right">
                            <?php
                                function val_tel($number){
                                    return preg_match('/^\d{11}$/', $number);
                                }
                                if(val_tel($tel)){
                                    echo $tel;
                                }else{
                                    echo"无效手机号";
                                }
                            ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="tr_left">学&nbsp;&nbsp;&nbsp;校:</td>
                        <td class="tr_right" colspan="3">
                            <?php
                                switch($school){
                                    case "hncst":
                                        echo "海软";
                                        break;
                                    case "hnrd":
                                        echo "海热";
                                        break;
                                    case "bd":
                                        echo "北京大学";
                                        break;
                                    case "qh":
                                        echo "清华大学";
                                        break;
                                    case "zkd":
                                        echo "中国科学技术大学";
                                        break;
                                    case "hd":
                                        echo "海南大学";
                                        break;
                                }
                            ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="tr_left">现居住地:</td>
                        <td class="tr_right" colspan="3">
                            <?php
                                echo $address;
                            ?>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="main">
            <div class="main_1">
                <h3><i class="fa fa-hand-o-right" style="font-size:36px"></i>培训技能</h3>
                <div class="cover">
                    <?php
                        for($i=0;$i<count($skill);$i++){
                            switch($skill[$i]){
                                case "driver":
                                    echo "开车"." " ;
                                break;
                                case "cook":
                                    echo "做菜"." ";
                                break;
                                case "pinao":
                                    echo "弹琴"." ";
                                break;
                            }
                        }
                    ?>    
                </div>
            </div>
            <div class="main_2">
                <h3><i class="fa fa-hand-o-right" style="font-size:36px"></i>兴趣爱好</h3>
                <div class="cover">
                    <?php
                        for($i=0;$i<count($love);$i++){
                            switch($love[$i]){
                                case "dance":
                                    echo "跳舞"." " ;
                                break;
                                case "sing":
                                    echo "唱歌"." ";
                                break;
                                case "chess":
                                    echo "下棋"." ";
                                break;
                                case "ball":
                                    echo "踢球"." ";
                                break;
                            }
                        }
                    ?>
                   
                </div>
            </div>
            <div class="main_3">
                <h3><i class="fa fa-hand-o-right" style="font-size:36px"></i>自我评价</h3>
                <div class="cover_bottom">
                    <?php
                        echo $introduce;
                    ?>
                    
                </div>
            </div>
            <div class="bottom">
                该简历由"敲会代码"小组万某人,孙某人,🐏某人制作完成
            </div>
        </div>
    </div>
</body>
</html>

说明:此项目是笔者在学校的小项目,因为笔者的能力有限,可能会出现很多没有想到的问题,如果您在浏览或者运行代码的时候出现了问题,请您在评论区留言,笔者在看到后会在第一时间处理,谢谢。

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
使用HTMLCSS制作一个简单个人网页,您可以按照以下步骤进行操作: 1. 创建HTML文件:打开文本编辑器(如Notepad++、Sublime Text等),新建一个空白文件,并将其保存为`.html`扩展名(例如,`index.html`)。 2. 编写HTML结构:在HTML文件中,使用标签来定义页面的结构。例如,可以使用`<html>`标签作为根元素,并在其中添加`<head>`和`<body>`标签。在`<body>`标签中,添加网页的内容。 3. 添加标题和元数据:在`<head>`标签中,使用`<title>`标签来定义网页的标题。还可以添加其他元数据,如字符编码和关键词等。 4. 创建内容部分:在`<body>`标签中,使用合适的标签来创建网页的内容。例如,可以使用`<header>`标签添加页眉,使用`<nav>`标签添加导航栏,使用`<section>`标签添加主要内容等。 5. 使用CSS样式:创建一个单独的CSS文件(例如,`styles.css`),将其与HTML文件放在同一目录下。在HTML文件的`<head>`标签中,使用`<link>`标签将CSS文件链接到HTML文件中。然后,在CSS文件中编写样式规则来定义网页的外观。 6. 设计页面布局:使用CSS的布局属性(如`display`、`position`、`float`等)来调整页面的布局。您可以使用CSS选择器来选择特定的HTML元素,并为其应用样式。 7. 定义样式:使用CSS属性来定义元素的样式,如颜色、背景、字体、边框等。您可以使用CSS选择器和类来选择特定的元素,并应用相应的样式。 8. 优化响应式设计:使用CSS媒体查询(`@media`)来创建响应式设计,使网页在不同屏幕大小和设备上都能适应良好。 9. 保存并预览:保存HTMLCSS文件,并在浏览器中打开HTML文件,以查看最终效果。 这些是制作简单个人网页的基本步骤,您可以根据需要进一步探索和学习更多的HTMLCSS知识,以创建更复杂和吸引人的网页。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

与风过山岗

您的鼓励是我莫大的荣幸

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值