当前位置:Gxlcms > 数据库问题 > form提交表单到数据库

form提交表单到数据库

时间:2021-07-01 10:21:17 帮助过:6人阅读

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>登录angularJS</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/login.css" />
    </head>
    <body>
        <div class="container">
            <div class="img-responsive"></div>
            <form class="form-signin" id= "form1" method="post" action="login.php">
                <h2>Please sign in</h2>
                <label class="sr-only" for="inputEmail" >Email address</label>
                <input id="inputEmail" class="form-control" placeholder="Email address" required=""
                    autofocus="" type="email" name="email"/>
                <label class="sr-only" for="inputPassword" >Password</label>
                <input id="inputPassword" class="form-control" placeholder="Password" required=""
                    autofocus="" type="password" name="password"/>
                    <div class="checkbox">
                        <label>
                            <input value="rember-me" type="checkbox" />
                            Remeber me
                        </label>
                    </div>
                    <button class="btn btn-lg btn-primary btn-block">Sign in</button>
            </form>
        </div>
    </body>
    
</html>

<?php
    header("content-type:text/html;charset=utf-8");
/* $mysql_username="localhost"; // 连接数据库用户名
    $mysql_password=""; // 连接数据库密码*/
    $mysql_database="test"; // 数据库的名字
    
    // 连接到数据库
   $conn = mysql_connect(‘localhost‘,‘root‘,‘‘) or die("MYSQL_connect:".mysql_errno());
    mysql_select_db($mysql_database);
     $email=$_POST[‘email‘];
     $password=$_POST[‘password‘];
    if(isset($email)){
    $sql = "INSERT INTO `login` VALUES (‘$email‘,‘$password‘)";
    
    $query = mysql_query($sql);
   if($query){
        echo ‘1‘;
    }else{
        echo ‘注册失败!‘;
        }
       }

?>

form提交表单到数据库

标签:表单提交 数据库

人气教程排行