• 建表以及 增。删。改。查


    //表单

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <form name='form1' action="./041301.php" method="post" enctype='multipart/data-file'>
    <p>
    用户名:<input type='text' name='user_name' />
    </p>
    <p>
    头像:<input type='file' name='user_img' />
    </p>
    <p>
    密码:<input type='password' name='user_pwd1' />
    </p>
    <p>
    确认密码:<input type='password' name='user_pwd2' />
    </p>
    <p>
    性别:<input type='radio' name='sex' value='1' checked='checked' />男
    <input type='radio' name='sex' value='0' />女
    </p>
    <p>
    邮箱:<input type='text' name='user_email' />
    </p>
    <p>
    <input type='submit' name='submit' value='注册' />
    <input type='reset' name='reset' value='重置' />
    </p>
    </form>
    </body>
    </html>

    //数据接收、显示

    <?php
    $user_name=$_POST['user_name'];
    $user_pwd=$_POST['user_pwd1'];
    $sex=$_POST['sex'];
    $user_email=$_POST['user_email'];
    $time=$_SERVER['REQUEST_TIME'];
    $host='localhost';
    $username='root';
    $userpwd='root';
    mysql_connect($host,$username,$userpwd);
    mysql_select_db('sankea');
    mysql_query('set names "utf8"');
    $userinfo="insert into cs_user1(user_name,user_password,sex,email,createtime)";
    $userinfo.=" values('$user_name','$user_pwd','$sex','$user_email','$time')";
    $li= mysql_query($userinfo);
    if($li)echo'注册成功!';
    else echo mysql_errno().mysql_error();
    ?>

    //数据的读取

    <?php
    date_default_timezone_set('Etc/GMT');
    echo '<meta charset="utf-8">';
    $vn=mysql_connect('127.0.0.1','root','root');
    mysql_select_db('sankea');
    $fetch_sql='select * from cs_user1';
    $fetch=mysql_query($fetch_sql);
    $rows=[];
    while ($row=mysql_fetch_array($fetch,MYSQL_ASSOC)){
    $rows[]=$row;
    }
    // mysql_close($vn);
    echo "<table border='0' align='center'>";
    echo '<tr><th>ID</th><th>用户名</th><th>地址</th><th>密码</th><th>性别</th><th>邮箱</th><th>注册时间</th><th>修改</th></tr>';
    foreach ($rows as $value){
    $time=date('Y-n-d H:n:s',$value['createtime']);
    if($value['sex']=='1')$sex="男";
    else $sex="女";
    $tab= "<tr align='center'><td>$value[id]</td><td>$value[user_name]</td><td>$value[img]</td>";
    $tab.="<td>$value[user_password]</td><td>$sex</td><td>$value[email]</td><td>$time</td>";
    $tab.="<td><a href='./update.php?user_name=".$value[user_name]."' target='_blank'>修改</a></td></tr>";
    echo $tab;
    }
    echo '</table>';
    $value[user_name];
    ?>

    //数据修改

    <?php
    $vn=mysql_connect('127.0.0.1','root','root');
    mysql_select_db('sankea');
    $sql='update cs_user1 set user_name="'.$_POST[user_name].'",';
    $sql.='user_password="'.$_POST[user_password].'",';
    $sql.='sex="'.$_POST[sex].'",';
    $sql.='email="'.$_POST[email].'"where id='.$_POST[id];
    $sq=mysql_query($sql);
    if($sq)echo '更改成功!';
    else echo mysql_errno().mysql_error();

    ?>

  • 相关阅读:
    Spring 中众多的的Initializer
    Spring Factories
    spring 的各种context
    @import和@Bean的区别,以及ImportSelector和ImportBeanDefinitionRegistrar两个接口的简单实用
    Spring 配置的方式
    记一次JAVA FULL GC问题处理【3】
    关于String, StringBuilder,StringBuffer 的一些测试数据
    记一次JAVA FULL GC问题处理【2】
    ThreadLocal 结构
    记一次JAVA FULL GC问题处理【1】
  • 原文地址:https://www.cnblogs.com/yucaiyun/p/6734459.html
Copyright © 2020-2023  润新知