OK, here is a smaller version of the file... it also gives me the same problem, a blank page "register4" case. If I comment out "mkglobal" part, I get "black field" error.
<?php
require_once("backend.php");
dbconn();
switch($_POST['action'])
{
default:
echo "<br>";
echo "<table cellpadding=3 cellspacing=0 class=t3>";
echo "<form method=post action=test.php name=registration>";
echo "<input name=action type=hidden value=register3>";
echo "<tr>";
echo "<td></td>";
echo "<td align=right>Username:</td>";
echo "<td><input type=text name=username maxlength=10 class=in style=width:225px;></td>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td align=right>Password:</td>";
echo "<td><input type=password name=password class=in style=width:225px; onkeyup=javascript:z21(document.forms[0],this.value); onmouseout=javascript:z21(document.forms[0],this.value); onblur=javascript:z21(document.forms[0],this.value);></td>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td align=right>Email:</td>";
echo "<td><input type=text name=email class=in style=width:225px;></td>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td align=right>Question:</td>";
echo "<td><input type=text name=question class=in style=width:225px;></td>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td align=right>Answer:</td>";
echo "<td><input type=text name=answer class=in style=width:225px;></td>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td></td>";
echo "<td><input type=button value=Cancel onclick=javascript:history.go(-1) class=bt style=width:60px;> <input type=reset value=Reset class=bt style=width:60px;> <input type=submit value='Continue' class=bt style=width:60px;></td>";
echo "</tr>";
echo "</form>";
echo "</table>";
break;
case "register1":
break;
case "register2":
break;
case "register3":
if (!mkglobal("username:password:email:question:answer"))
die();
if (empty($username) || empty($password) || empty($email) || empty($question) || empty($answer))
echo "blank field";
echo "<br>";
echo "<table cellpadding=3 cellspacing=0 class=t3>";
echo "<form method=post action=test.php name=registration>";
echo "<input name=action type=hidden value=register4>";
echo "<input name=username type=hidden value='$username'>";
echo "<input name=password type=hidden value='$password'>";
echo "<input name=email type=hidden value='$email'>";
echo "<input name=question type=hidden value='$question'>";
echo "<input name=answer type=hidden value='$answer'>";
echo "<tr>";
echo "<td></td>";
echo "<td align=right>Security Image:</td>";
echo "<td>456321</td>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td align=right>Image Code:</td>";
echo "<td><input type=text name=privatekey maxlength=6 class=in style=width:225px; autocomplete=off></td>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td></td>";
echo "<td><input type=button value=Cancel onclick=javascript:history.go(-1) class=bt style=width:60px;> <input type=reset value=Reset class=bt style=width:60px;> <input type=submit value='Continue' class=bt style=width:60px;></td>";
echo "</tr>";
echo "</form>";
echo "</table>";
break;
case "register4":
if (!mkglobal("username:password:email:question:answer:privatekey"))
die();
if (empty($username) || empty($password) || empty($email) || empty($question) || empty($answer) || empty($privatekey))
echO "blank field.";
if ($privatekey !== '456321')
echo "Code didn't match. Please go back and try again.";
if (!preg_match('/^[a-z][\w.-][\w. ]*$/is', $username))
echo "Invalid username. Must not contain any weird characters and must start with a letter.");
$ret = mysql_query("INSERT INTO users (username, password, email, question, answer) VALUES (" .
implode(",", array_map("sqlesc", array($username, $password, $email, $question, $answer))) .")");
if (!$ret)
{
if (mysql_errno() == 1062)
{
echo "<br>";
echo "<table cellpadding=3 cellspacing=0 class=t3>";
echo "<tr>";
echo "<td></td>";
echo "<td align=right>Error:</td>";
echo "<td>The username you've choosen exists already.</td>";
echo "</tr>";
echo "<tr>";
echo "<td></td>";
echo "<td></td>";
echo "<td><input type=button value=Cancel onclick=javascript:history.go(-1) class=bt style=width:60px;> <input type=reset value=Reset class=bt style=width:60px;> <input type=submit value='Continue' class=bt style=width:60px;></td>";
echo "<td></td>";
echo "</tr>";
echo "</table>";
}
}
else
{
echo "Successful";
}
break;
}
?>
and here a function just in case:
function mkglobal($vars)
{
if (!is_array($vars))
$vars = explode(":", $vars);
foreach ($vars as $v)
{
if (isset($_GET[$v]))
$GLOBALS[$v] = unesc($_GET[$v]);
elseif (isset($_POST[$v]))
$GLOBALS[$v] = unesc($_POST[$v]);
else
return 0;
}
return 1;
}
and here is the users table:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(14) NOT NULL DEFAULT '',
`password` varchar(40) NOT NULL DEFAULT '',
`email` varchar(32) NOT NULL DEFAULT '',
`question` char(2) NOT NULL DEFAULT '',
`answer` varchar(32) NOT NULL DEFAULT '',
`lastrequest` datetime NOT NULL,
`upstatus` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=34 ;