html登陆跳转到php页面连接数据库,提示提交未成功
这是HTML中的form:
<form action="logincheck.php" method="post" entcy="multipart/form-data" name="form1" id="form1">
<div class="control-group">
<lable class="laber_form">学号</lable>
<div class="controls">
<input class="username" name="username" type="text" placeholder="请输入用户名" />
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<label class="laber_form">密码</label>
<div class="controls">
<input class="password" name="password" type="password" placeholder="请输入密码" />
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<label class="laber_form"></label>
<div class="controls">
<button class="btn btn-success" type="submit" name="sumbit" style="width:120px;" value="登陆" >登陆</button>
<a class="regist" href="register.html" onmouseover="this.style.color = '#DAA520'" onmouseout=" this.style.color = '#F5F5F5'" style="color:#F5F5F5">立即注册</a>
</div>
</div>
</form>
这是php的登陆连接数据库php:
<?php
if(isset($_POST["submit"])&&$_POST["submit"]=="登陆")
{
$user = $_POST["username"];
$psw = $_POST["password"];
if($user == "" || $psw == "")
{
echo "<script>alert('请输入用户名或密码!'); history.go(-1);</script>";
}
else
{
$con=mysql_connect("127.0.0.1","root","1234");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("vote");
mysql_query("set names 'utf-8'");
$sql = "select 用户名 from 密码表 where 用户名 = '$_POST[username]' and 密码 = '$_POST[password]'";
$result = mysql_query($sql);
if($result)
{
echo $username,' 欢迎你!进入 <a href="my.php">用户中心</a><br />';
}
else
{
echo "<script>alert('用户名或密码不正确!');history.go(-1);</script>";
}
}
}
else
{
echo "<script>alert('提交未成功!'); history.go(-1);</script>";
}
?>