<?php
require_once("conn.php");
error_reporting(0);//不显示错误报告
$username=str_replace(" ","",$_GET['f_username']);
$password=$_GET['f_password'];
$email=$_GET['f_email'];define("ZINGBLUE","loveair");//md5加上字符串验证更加安全
$password=$password.ZINGBLUE;
$sql="select * from user where username=".$username;
$result=mysql_query($sql);
$row=mysql_fetch_array($result);if(is_array($row))
{
print "returnInfo=REG_CZ";//用户名已经存在,返回到FLASH中
}else
{
$insertStr="insert into user(username,password,email) values('$username',md5('$password'),'$email')";
$insertResult=mysql_query($insertStr);
if($insertResult)
{
print "returnInfo=REG_OK";
print $username;
}else
{
print "returnInfo=REG_ERROR";
}
}
?>------------------------------
请判断一下~ 如果$username,$password,$email 这3个~ 任何一个为空~~ 都不执行~SQL~~ 且返回上页~~~~
我新学的~~ 不知道代码怎么改~~~~~~~~~
if($username=="")
{
echo"<script>alert('用户名不能为空!');windows.history.back();</script>"; }
你试试吧,不懂再问。
{
//为空
}
else
{
//不为空
} if($username!="" and $password!="" and $email!="")
{
//不为空
}
else
{
//为空
}
if($username=='' or $password=='' or $email=='') { echo "<script language='javascript'>alert('所有项目不能为空!');history.back(0);</script>"}else{ //SQL语句}