Error! Please enter a username

"; $valid=false; } if(empty($_REQUEST['password'])) { print "

Error! Please enter a password

"; $valid=false; } if(empty($_REQUEST['fullname'])) { print "

Error! Please enter the full name

"; $valid=false; } if(!$valid) print "

Back to Input Form

"; return $valid; } function validUser() { $username = addslashes($_REQUEST['username']); $query="SELECT fullName FROM User_T WHERE userName='$username'"; $result=mysql_query($query); if (mysql_num_rows($result)==1) { print "

Error! User $username already exists

"; print "

Back to Input Form

"; return false; } return true; } function addUser() { if(isset($_REQUEST['isadmin'])) $isAdmin='true'; else $isAdmin='false'; $username = addslashes($_REQUEST['username']); $password = addslashes($_REQUEST['password']); $fullname = addslashes($_REQUEST['fullname']); $query = "INSERT INTO User_T(username, passwd, fullName, isAdmin) VALUES('$username', SHA('$password'), '$fullname', $isAdmin)"; $result = mysql_query($query); if($result) print "

User $username successfully added

"; else print "

Adding user $username failed

"; print "

Back to Input Form

"; } if (validIncomingData() && validUser()) addUser(); ?>