我编写的这段代码由于未知原因无法正常工作。PHP 不报告任何错误或警告。
<html>
<head>
<title>PHP Blog</title>
</head>
<body>
<?php
require 'login.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($db_database, $db_server)
or die("Unable to select database: " . mysql_error());
if(isset($_POST['username']) and isset($_POST['password']))
{
$pass = "test";
$user = "test";
if($_POST['username'] == "test" and $_POST['password'] == "test")
{
echo <<<_END
<form action="post.php" method="post"><pre>
Title: <input type="text" name="title">
Post: <textarea rows="5" cols="64" name="post">
</textarea>
<input type="submit" value="Submit">
</pre></form>
_END;
if(isset($_POST['title']) and isset($_POST['post']))
{
$title = $_POST['title'];
$post = $_POST['post'];
$query = "INSERT INTO blog(title,post) VALUES('$title', '$post')";
mysql_query($query);
echo 'Succesfully posted..';
echo '<a href="blog.php">Click here</a>';
}
}
else
{
echo "Wrong Password!";
}
}
?>
一切正常,直到我设置变量$_POST['title']
并$_POST['post']
单击按钮。当我这样做时,我只会得到一个空白页。