怎么用php实现提交表单时验证用户的效果 这个不是一条sql语句加个判断就可以实现的不? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 但是怎么实现呀?我现在的问题是1.如果我提交表单的话可以打开另一页但是我不能控制它的大小2.如果我不提交表单的话我有不能得到文本框的内容,可以用js的window.open()控制 <input type="button" onlcik="window.open('check.php?userName='+document.form.username.value )";check.php:<?php $sql = "select id from user where username='" . $_GET['userName'] + "'"; .... ....?> 为什么是这个呀"underfined" test.php<form action="text.php" method="post"><input type="text" name= username><input type="submit" name=submit value="验证用户"></form><?if($submit){ $username = $_GET['username']; $sql = "select * from user_table where username='$username'"; $res = mysql_query($sql); $num = mysql_num_rows($res) if ($num==0) { echo "<script language='javascript'>alert('无此用户!!');</script>" } else { echo "<script language='javascript'>alert('此用户存在!!');</script>" }}?> 同意 unixdotnet() 就是无刷新查询的问题另外,窗口大小参照如下window.open("Sample.htm",null, "height=200,width=100,status=yes,toolbar=no,menubar=no,location=no"); $connect=mysql_connect("localhost","root","");$select=mysql_select_db("数据库名",$connect);$sel=mysql_query("select * from 表 where name='.$_GET[$name].'",$connect);if($sel){echo '<script language="javascript"><!--alert("用户名已存在!");location="no14_bd.php";//--></script>';exit();} 他的想法应该是把变量提交到一个新窗口中,并且新窗口是可以控制大小的,应该使用JS来控制,我的代码:[JS好象写的有点问题,高手帮忙看看...]/*文件: Submit.php作用: 使用JS来提交变量*/<Script language="JavaScript"> function Check_User() //定义一个JS函数,用来把变量提交给CheckUser.php处理 { document.checkme.Username.value=document.regme.username.value;var popupWin = window.open('Check_User.php', 'Check', 'scrollbars=no,width=240,height=80,top=200,left=200'); document.checkme.submit() } function Check(theForm) { if (theForm.username.value == "") { alert("请输入您的用户名!"); theForm.username.focus(); return (false); } }</Script><form action="Reg.asp" method="Post" name="regme" onSubmit="return Check(regme)"> <input type=text name=username> <input type=submit value='提交' onClick='Check_User()'></form>/*文件: CheckUser.php作用: 检测该用户是否存在*/<?$connect = mysql_connect($host,$user,$passwd);$sql = "select * form table";...... //验证的代码?> 有人做过facebook application的开发吗? php include父页面与子页面之间变量传递问题?? 『新手』请问,为什么用127.0.0.1不能打开PHP文件,而LOCALHOST能打开? 谁二次开发过UCenter php中html标签显示问题 菜鸟求助一个基本语法问题 在php中如何把字符串表示的日期进行比较前后,计算当前日期加一定间隔后的日期? 关于mysql表中空闲字段值的查找? 函数中post变量传递问题? 数据库问题? 怎样输出重数据库中读取数据的数组的键名? 高手请进!
我现在的问题是1.如果我提交表单的话可以打开另一页但是我不能控制它的大小
2.如果我不提交表单的话我有不能得到文本框的内容,可以用js的window.open()控制
$sql = "select id from user where username='" . $_GET['userName'] + "'";
....
....
?>
<form action="text.php" method="post">
<input type="text" name= username>
<input type="submit" name=submit value="验证用户">
</form>
<?
if($submit)
{
$username = $_GET['username'];
$sql = "select * from user_table where username='$username'";
$res = mysql_query($sql);
$num = mysql_num_rows($res)
if ($num==0)
{
echo "<script language='javascript'>alert('无此用户!!');</script>"
}
else
{
echo "<script language='javascript'>alert('此用户存在!!');</script>"
}
}?>
就是无刷新查询的问题
另外,窗口大小参照如下
window.open("Sample.htm",null,
"height=200,width=100,status=yes,toolbar=no,menubar=no,location=no");
$select=mysql_select_db("数据库名",$connect);
$sel=mysql_query("select * from 表 where name='.$_GET[$name].'",$connect);
if($sel){
echo '
<script language="javascript">
<!--
alert("用户名已存在!");
location="no14_bd.php";
//-->
</script>
';
exit();
}
文件: Submit.php
作用: 使用JS来提交变量
*/<Script language="JavaScript">
function Check_User() //定义一个JS函数,用来把变量提交给CheckUser.php处理
{
document.checkme.Username.value=document.regme.username.value;
var popupWin = window.open('Check_User.php', 'Check', 'scrollbars=no,width=240,height=80,top=200,left=200');
document.checkme.submit()
}
function Check(theForm)
{
if (theForm.username.value == "")
{
alert("请输入您的用户名!");
theForm.username.focus();
return (false);
}
}
</Script><form action="Reg.asp" method="Post" name="regme" onSubmit="return Check(regme)">
<input type=text name=username>
<input type=submit value='提交' onClick='Check_User()'>
</form>
/*
文件: CheckUser.php
作用: 检测该用户是否存在
*/<?
$connect = mysql_connect($host,$user,$passwd);
$sql = "select * form table";
...... //验证的代码?>