我还是新编码,目前我正在用HTML和PHP做一些实验。
使用HTML创建了一个联系表单,当按下提交按钮时,我遇到了问题,屏幕上没有显示任何内容。我想现在输入数据,最后我想发送电子邮件。 HTML和PHP代码可以在下面找到。
<!DOCTYPE html>
<html>
<head>
<title>kurtattard.org</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>
<body>
<header>
<div class="logo"></div>
<nav class="nav">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Event</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<h1>Contact Us</h1>
</header>
<form>
<div class ="textform">
<form method="post" action="/contact.php">
<label>Name</Label>
<input type="text" name="name" placeholder="Insert your Name and Surname">
<label>Email</label>
<input type="text" name="email" placeholder="Insert your email address">
<label>Message</label>
<input type="message-box" name="message" placeholder="Enter your message">
<input type="submit" name="submit">
<!--<button type="submit" name="submit">Send Mail</button>-->
</form>
</div>
</body>
</html>
PHP:
<?php
if(isset($_POST['submit'])){ //someone submitted the form
if(isset($_POST['name'])){ //they entered a name or something
echo 'hello from ';
echo htmlentities(trim($_POST['name']),ENT_NOQUOTES);
}else{ //or they did not
echo 'type a name';
}
}
?>
答案 0 :(得分:2)
问题是您的代码中有小错字。您添加了额外的开放<!DOCTYPE html>
<html>
<head>
<title>kurtattard.org</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>
<body>
<header>
<div class="logo"></div>
<nav class="nav">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Event</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<h1>Contact Us</h1>
</header>
<!-- <form> Remove this -->
<div class ="textform">
<form method="post" action="contact.php">
<label>Name</Label>
<input type="text" name="name" placeholder="Insert your Name and Surname">
<label>Email</label>
<input type="text" name="email" placeholder="Insert your email address">
<label>Message</label>
<input type="message-box" name="message" placeholder="Enter your message">
<input type="submit" name="submit">
<!--<button type="submit" name="submit">Send Mail</button>-->
</form>
</div>
</body>
</html>
标记。删除它,你的代码将像魅力一样工作。
"HTTP/1.1 503 Service Unavailable\r\n"+
"Content-Type: text/html;charset=utf-8\r\n"+
"Strict-Transport-Security: max-age=31536000\r\n"+
"\r\n"+
"<!doctype html><html><body>
Backend server for " + HTTP.REQ.HOSTNAME + HTTP.REQ.URL.HTTP_URL_SAFE + " is not responding.
</body></html>"