每日博客

php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户信息</title>
</head>
<body>
<?php
session_start();
try
{
    $pdo = new PDO("mysql:host=localhost;dbname=test;", "root", "fx30001225");
}
catch (PDOException $e) {die("数据库连接失败" . $e->getMessage());}
$pdo->query("SET NAMES 'UTF8'");
$sql = "SELECT * FROM stu WHERE name =".$_SESSION['name'];
$stmt = $pdo->query($sql);//返回预处理对象
if ($stmt->rowCount() > 0) {$stu = $stmt->fetch(PDO::FETCH_ASSOC);}
?>
<h2 style="color: palegreen;text-align: center">您的个人资料如下</h2>
<hr color="red">
<div align="center">
    <H3 style="font-size: 25px">学生个人信息表</H3>
    <table border="1">
        <tr>
            <td>您的姓名:</td>
            <td><input  id="name" name="name" value="<?php echo $stu['name'] ?>"/></td>
        </tr>
        <tr>
            <td>性别:</td>
            <td><input type="text" name="sex" value="<?php echo $stu['sex'] ?>"/>
            </td>
        </tr>
        <tr>
            <td>年龄:</td>
            <td><input name="age" value="<?php echo $stu['age'] ?>"/>
            </td>
        </tr>
        <tr>
            <td>家庭住址:</td>
            <td><input name="address" value="<?php echo $stu['address'] ?>"/>
            </td>
        </tr>
        <tr>
            <td>特长爱好:</td>
            <td><input name="sex" value="<?php echo $stu['hobby'] ?>"/>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <a href='ex02d.php?id=<?php echo $stu['id'] ?>'>修改</a>
                <a href='act02.php?action=del&id=<?php echo $stu['id'] ?>'>删除</a>
            </td>
        </tr>
    </table>
    <a style="align-self: center" href="ex02a.php">返回首页</a>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
</head>
<body>
<div align="center">
    <H3 style="color: palegreen;font-size: 25px">用户登录</H3>
    <form action="act02.php?action=login" method="post">
        <table border="1">
            <tr>
                <td>姓名:</td>
                <td><input id="name" name="name" type="text"/></td>
            </tr>
            <tr>
                <td>性别:</td>
                <td><input type="radio" name="sex" value="男" checked/><input type="radio" name="sex" value="女"/></td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="submit" value="提交"/>  
                    <input type="reset" value="重置"/>  
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>

 

posted @ 2021-09-26 19:21  谦寻  阅读(45)  评论(0编辑  收藏  举报