HTML 联系表格 - HTML
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HTML 联系表格 - HTML相关的知识,希望对你有一定的参考价值。
<form action="" method="post" class="">
<h1>Contact Form
<span>Please fill all field</span>
</h1>
<label>
<span>Your Name :</span>
<input type="text" id="name" name="name"/>
</label>
<label>
<span>Your Email :</span>
<input type="text" id="email" name="email"/>
</label>
<label>
<span>Message :</span>
<input type="text" id="message" name="message"/>
</label>
<label>
<span>subject</span>
<select name="subject" id="">
<option value="question">question</option>
<option value="suggest">suggest</option>
</select>
</label>
<label>
<span>&nbsp;</span>
<input type="button" value="send" />
</label>
</form>
PHP HTML联系表格流程
PART 1
--------------------------------------------------
<table width="60%" border="0" align="center" cellpadding="6" cellspacing="2">
<tr>
<td><div align="right">
<label for="textfield">Name:</label>
</div></td>
<td><div align="left">
<input name="name" type="text" id="Name" size="45" maxlength="100" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="label">Email:</label>
</div></td>
<td><div align="left">
<label for="label"></label>
<input name="email" type="text" id="Email" size="45" maxlength="100" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="label2">Message:</label>
</div></td>
<td><div align="left">
<textarea name="message" cols="45" rows="5" id="Message"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right">
<label>
<input name="clear" type="reset" id="clear" value="Clear All" />
</label>
</div></td>
<td><div align="left">
<label for="Submit"></label>
<input name="send" type="submit" id="send" onclick="MM_validateForm('Name','','R');MM_validateForm('Email','','RisEmail');MM_validateForm('Message','','R');return document.MM_returnValue" value="Send!" />
</div></td>
</tr>
</table>
PART 2
---------------------------------------------------------
<?php
//setting variables
$emailSubject = 'Contacted!';
$webMaster = 'YOUREMAIL!';
//gathering data variables
$email = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['message'];
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Message: $message <br>
<br>
EOD;
$headers = "From: $email
";
$headers .= "Content-type: text/html
";
$success = mail($webMaster, $emailSubject, $body, $headers);
//displaying results as HTML
$results = <<<EOD
<html>
<head>
</head>
<body>
<hr/>
<p><a href="index.html">Go Back</a></p>
</body>
<html>
EOD;
echo "$results";
?>
以上是关于HTML 联系表格 - HTML的主要内容,如果未能解决你的问题,请参考以下文章