我没填写资料就提交,按道理应该提示我没填写资料啊? 我错再哪、、、我发现木了?
<?php
include "comm.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script type="text/javascript">
function check(){
if(myform.user_name.value==""){
alert("用户名不能为空!");
return false;
}
if(myform.pw1.value=="" | myform.pw2.value==""){
alert("密码不能为空!");
return false;
}
if(myform.pw1.value!=myform.pw2.value){
alert("两次输入的密码不一致!")
return false;
}
return true;
}
</script>
<?php
if(isset($_POST['user_name'])){
$user = $_POST['user_name'];
$pw = md5($_POST['pw1']);
$conn = mysql_connect("localhost","root","123456");
mysql_select_db("course");
$sql = "insert into user_table (user_name,pw) values('$user','$pw')";
mysql_query("set names 'gb2312'");
mysql_query($sql,$conn);
mysql_close($conn);
get_show_msg("login.php","注册成功");
}
?>
<style type="text/css">
#table{text-align:center;
}
</style>
<body>
<form id=myform name=myform action="" method=post onsubmit="return check();">
<table width="300" border="1" cellspacing="1" cellpadding="1" align="center" id="table">
<tr>
<td>账号:<input type="text" name="user_name" id="user_name"><br></td>
</tr>
<tr>
<td>第一次密码:<input type="password" name="pw1" id="pw1"><br></td>
</tr>
<tr>
<td>第二次密码:<input type="password" name="pw2" id="pw2"><br></td>
</tr>
<tr>
<td><input type="button" value="提交"><input type="reset" name="重置"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
include "comm.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script type="text/javascript">
function check(){
if(myform.user_name.value==""){
alert("用户名不能为空!");
return false;
}
if(myform.pw1.value=="" | myform.pw2.value==""){
alert("密码不能为空!");
return false;
}
if(myform.pw1.value!=myform.pw2.value){
alert("两次输入的密码不一致!")
return false;
}
return true;
}
</script>
<?php
if(isset($_POST['user_name'])){
$user = $_POST['user_name'];
$pw = md5($_POST['pw1']);
$conn = mysql_connect("localhost","root","123456");
mysql_select_db("course");
$sql = "insert into user_table (user_name,pw) values('$user','$pw')";
mysql_query("set names 'gb2312'");
mysql_query($sql,$conn);
mysql_close($conn);
get_show_msg("login.php","注册成功");
}
?>
<style type="text/css">
#table{text-align:center;
}
</style>
<body>
<form id=myform name=myform action="" method=post onsubmit="return check();">
<table width="300" border="1" cellspacing="1" cellpadding="1" align="center" id="table">
<tr>
<td>账号:<input type="text" name="user_name" id="user_name"><br></td>
</tr>
<tr>
<td>第一次密码:<input type="password" name="pw1" id="pw1"><br></td>
</tr>
<tr>
<td>第二次密码:<input type="password" name="pw2" id="pw2"><br></td>
</tr>
<tr>
<td><input type="button" value="提交"><input type="reset" name="重置"></td>
</tr>
</table>
</form>
</body>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script>
function check(myform){
if(myform.user_name.value==""){
alert("用户名不能为空!");
return false;
}
if(myform.pw1.value=="" | myform.pw2.value==""){
alert("密码不能为空!");
return false;
}
if(myform.pw1.value!=myform.pw2.value){
alert("两次输入的密码不一致!")
return false;
}
return true;
}
</script><style type="text/css">
#table{text-align:center;
}
</style>
<body>
<form id=myform name=myform action="" method=post onsubmit="return check(this);">
<table width="300" border="1" cellspacing="1" cellpadding="1" align="center" id="table">
<tr>
<td>账号:<input type="text" name="user_name" id="user_name"><br></td>
</tr>
<tr>
<td>第一次密码:<input type="password" name="pw1" id="pw1"><br></td>
</tr>
<tr>
<td>第二次密码:<input type="password" name="pw2" id="pw2"><br></td>
</tr>
<tr>
<td><input type="submit" value="提交"><input type="reset" name="重置"></td>
</tr>
</table>
</form>
</body>
</html><input type="submit" value="提交">
++