码迷,mamicode.com
首页 > 数据库 > 详细

form提交表单到数据库

时间:2016-05-13 04:55:07      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:表单提交 数据库

<!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提交表单到数据库

标签:表单提交 数据库

原文地址:http://warmdoll.blog.51cto.com/10881334/1772741

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!