• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

每日总结

开发技术 开发技术 4小时前 3次浏览

学习SQL server数据库以及完成php操作数据库的实验

<?php
$servername = "localhost:3306";
$username = "root";
$password = "";
$dbname = "php_lab04";
global $conn;
// 创建连接
$conn = mysqli_connect($servername, $username, $password, $dbname);
// 检测连接
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$conn->query('set names utf8');
function getConnection(){
    $servername = "localhost:3306";
    $username = "root";
    $password = "whyjlbcdy2001";
    $dbname = "php_lab04";
    return mysqli_connect($servername, $username, $password, $dbname);
}
<html>
<head>
    <title>添加个人资料</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<form name="info" action="ex01b.php" method="post" onsubmit="return check()">
    <h2>添加个人资料</h2>
    <table style="width: 50%">
        <tr>
            <th>真实姓名:</th>
            <td><input name="name" type="text"></td>
        </tr>
        <tr>
            <th>性别:</th>
            <td>
                <input type="radio" name="sex" value="男"><input type="radio" name="sex" value="女"></td>
        </tr>
        <tr>
            <th>兴趣爱好:</th>
            <td><input type="text" name="hobby"></td>
        </tr>
        <tr>
            <th>家庭住址:</th>
            <td>
                <select name="address">
                    <option value ="密云区">密云区</option>
                    <option value ="延庆区">延庆区</option>
                    <option value="朝阳区">朝阳区</option>
                    <option value="丰台区">丰台区</option>
                    <option value="石景山区">石景山区</option>
                    <option value="海淀区">海淀区</option>
                    <option value="门头沟区">门头沟区</option>
                    <option value="房山区">房山区</option>
                    <option value="通州区">通州区</option>
                    <option value="顺义区">顺义区</option>
                    <option value="昌平区">昌平区</option>
                    <option value="大兴区">大兴区</option>
                    <option value="怀柔区">怀柔区</option>
                    <option value="平谷区">平谷区</option>
                    <option value="东城区">东城区</option>
                    <option value="西城区">西城区</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>备注:</th>
            <td><textarea name="notes" rows="6" cols="45"></textarea></td>
        </tr>

        <tr>
            <td colspan="2">
                <input type="submit" name="submit" value="提交">
                <input type="reset" value="重置">
            </td>
        </tr>
    </table>
</form>

</body>
<script type="text/javascript">
    function check(){
        if(info.name.value==""||info.name.value==null){
            alert("请输入真实姓名!");
            return false;
        }
        if(info.sex.value==""||info.sex.value==null){
            alert("请选择性别!");
            return false;
        }
        if(info.hobby.value==""||info.hobby.value==null){
            alert("请填写兴趣爱好!");
            return false;
        }
        if(info.address.value==""||info.address.value==null){
            alert("请选择地址!");
            return false;
        }
        if(info.notes.value==""||nfo.notes.value==null){
            alert("请填写备注!");
            return false;
        }
    }
</script>
</html>

 


程序员灯塔
转载请注明原文链接:每日总结
喜欢 (0)