我的 PHP/SQL 表单代码没有输出任何东西。我尝试调试它并回显变量,但仍然没有运气。在某些情况下,我为调试注释了回声,但它们不起作用。我对高级 php 了解不多,我认为该错误与 SQL 数据库连接有关,但 or die 不起作用。我是初学者。
<?php
define('DEBUG', TRUE);
echo "Starting...<br>";
//TIMEZONE SET
date_default_timezone_set('America/New_York');
//VERSION VARIABLES-------------------------------------------------------------------- -----------
$sysversion = '1';
//TIME DEPENDANT VARIABLES------------------------------------------------------------- ------------
$maxyear = '2004';
$minyear = '1890';
//USER INPUT VARIABLES-----------------------------------------------------------------------------
$email = mysql_real_escape_string($_POST['email']);
$username = mysql_real_escape_string($_POST['username']);
$pass1 = mysql_real_escape_string($_POST['pass1']);
$pass2 = mysql_real_escape_string($_POST['pass2']);
$first = mysql_real_escape_string($_POST['first']);
$last = mysql_real_escape_string($_POST['last']);
$sex = mysql_real_escape_string($_POST['sex']);
$bdaymonth = mysql_real_escape_string($_POST['bdaymonth']);
$bdayday = mysql_real_escape_string($_POST['bdayday']);
$byear = mysql_real_escape_string($_POST['bdayyear']);
$country = mysql_real_escape_string($_POST['country']);
$telcc = mysql_real_escape_string($_POST['telcc']);
$ac = mysql_real_escape_string($_POST['ac']);
$exc = mysql_real_escape_string($_POST['exc']);
$sta = mysql_real_escape_string($_POST['sta']);
$teltype = mysql_real_escape_string($_POST['teltype']);
$question = mysql_real_escape_string($_POST['question']);
$answer = mysql_real_escape_string($_POST['answer']);
//LOGICAL VARIABLES----------------------------------------------------------------------------------
if($pass1 == $pass2)
{
$password = $pass1;
}
echo "<br>$password<br>";
else
{
echo "<script type='text/javascript'>\n";
echo "alert('The passwords do not match.');\n";
echo "window.location = 'http://nematznetwork.no- ip.org/login/register.htm';\n";
echo "</script>";
echo 'PASS_ERROR';
}
if($byear < $maxyear)
{
$bdayyear = $byear;
echo "$bdayyear<br>";
}
else
{
echo "<script type='text/javascript'>\n";
echo "alert('You must be 10 years old to register.');\n";
echo "window.location = 'http://nematznetwork.no-ip.org/login/register.htm';\n";
echo "</script>";
echo 'ERROR';
}
if($byear > $minyear)
{
$bdayyear = $byear;
echo "$bdayyear<br>";
}
else
{
echo "<script type='text/javascript'>\n";
echo "alert('You are older than the worlds oldest person. Please enter your correct age.');\n";
echo "window.location = 'http://nematznetwork.no- ip.org/login/register.htm';\n";
echo "</script>";
echo 'ERROR';
}
$telnum = "$ac$exc$sta";
echo "$telnum<br>";
$regdate = date('Ymd,H:i:s');
echo "$regdate<br>";
function create($username, $password)
{
//MYSQL HEADERS----------------------------------------------------------------------------------------------------
$database = mysql_connect("localhost" , "root" , "PassWord123456789");
if(!$database)
{
if(DEBUG)
{
die("Failed to connect to database: " . mysql_error());
}
return FALASE;
}
echo "$database<br>";
mysql_select_db("nematznetwork", $database);
//MYSQL WRITE QUERY--------------------------------------------------------------------------------------------------
$queryw = "
INSERT INTO users (email, username, password, first, last, sex, bdaymonth, bdayday, bdayyear, country, telcc, telnum, teltype, question, answer, sysversion, regdate)
VALUES($email, $username, $password, $first, $last, $sex, $bdaymonth, $bdayday, $bdayyear, $country, $telcc, $telnum, $teltype, $question, $answer, $sysversion, $regdate)
";
//MYSQL INSERT COMMAND
mysql_query ($queryw, $database)
//GET USER ID
$queryr = "SELECT * FROM users WHERE username = '" . $username ."'";
echo "$queryr<br>";
$resource = mysql_query($queryr, $database);
if(!$resource)
{
if(DEBUG)
{
die("Failed to query database: " . mysql_error());
}
return FALASE;
}
//echo "$resource<br>";
$result = mysql_fetch_assoc($resource);
//echo "$result<br>";
$id = $result['ID'];
//echo "$id<br>";
//MAKE USER DIRECTORY
$path = './../users/' . $id . '/';
//echo "$path<br>";
mkdir($path)
//WRITE HTML FILES
$file = './../users/' . $id . '/default.htm';
//echo "$file<br>";
$write = '<html>\n<head>\n<meta http-equiv="Content-Language" content="en-us">\n<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">\n<title>' . $first $last . '- NematzNetwork</title>\n</head>\n<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">\n<iframe src=../../menu.htm width="100%" height="45" frameborder="0" scrolling="no" target="_parent"></iframe>\n<iframe src="body.htm" width="100%" height="90%" frameborder="0">\n</body target="_parent">\n</html>';
//echo "$write<br>";
file_put_contents($file , $write);
$file2 = './../users/' . $id . '/body.htm';
//echo "$file2<br>";
$write2 = '<html>\n<head>\n<meta http-equiv="Content-Language" content="en-us">\n<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">\n<title>NematzNetwork</title>\n<base target="_parent" />\n</head>\n<body bgcolor="#FFFFFF">\n\n</body>\n</html>';
//echo "$write2<br>";
file_put_contents($file2 , $write2);
//REDIRECT TO LOGIN PAGE-------------------------------------------------------------------------------------------------
//echo "<script type='text/javascript'>\n";
//echo "window.location = 'http://nematznetwork.no-ip.org/login/default.htm';\n";
//echo "</script>";
}
?>