0

代码在单独的文件中有效,但在包含在同一个 html 文件中时无效

完整的代码如下

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php
$connect=mysqli_connect("127.0.0.1","root","notmention","mysite");
if (mysqli_connect_errno($connect))
  {
  $txt="Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $txz="s";
?>
</head>
<body background="images/background.PNG">
<div align="center">
<form action="register.html" enctype="multipart/form-data" method="post"  >
<span style="color:#399">Create Account</span><br />
<input type="text" name="username" placeholder="Username" /><br />
<input type="text" name="password" placeholder="password" /><br />
<input type="text" name="email" placeholder="email" /><br />
<input type="submit" value="Submit"  /><br />
</form>
</div>
<div><?php echo $txt ?></div><br />
<div><?php echo $txz ?></div><br />

</body>
</html>
4

1 回答 1

0

您需要使用.php扩展名而不是.html来保存它

于 2013-06-18T11:48:43.233 回答