mysql 注册登陆表单并且操纵元素

时间:2023-03-09 02:31:00
mysql 注册登陆表单并且操纵元素

<?php
     error_reporting(E_ALL^E_DEPRECATED^E_NOTICE);
    header("content-type:text/html;charset=utf8");
 mysql_connect("localhost","root","")or die("数据库连接失败");
 mysql_select_db("lidepeng") or die("数据库选择失败");

if($_POST['sub']){
     $username=$_POST['username'];
     $password=$_POST['password'];
     $insert="insert into lidepeng(username,password)values('$username','$password') ";
    
    
      $result=  mysql_query($insert);
      if(!$result){
          echo "注册失败";
      }
      else{
          echo   
    " <span > 注册成功 <span>";
      }    
 }
 ?>
 <html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <style type="text/css">
        span{
            position: absolute;left: 150px;top: 130px;
        }
        body{
            background-color:lightcyan;
        }
            form{
                
                position: absolute;top: 300px;left: 200px;
            }
        </style>
    </head>
    <body>
        
        <form action="index.php" method="post">
            用户名:    <input type="text" name="username" id="username" required="required" />
    <br />密码:<input type="text" name="password" id="password"  required="required"/>
            <input type="submit" value="注册" name="sub"/>
        </form>
        </body>
</html>