我对编写php相当陌生,我有一个注册表单,我希望将信息发送到我的电子邮件,但我认为我的mail.php中缺少一些东西,因为信息没有通过。
这是我的 html5 表单:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Register</title>
<link href="css/reset.css" rel="stylesheet" type="text/css">
<link href="css/register.css" rel="stylesheet" type="text/css">
</head>
<div id="container">
<section id="register">
<form action="mail.php" method="post" accept-charset="utf-8">
<h4>Your Jeep</h4>
<div class="form-field">
<fieldset>
<label>Year</label>
<input value="" placeholder="Year" type="text" name="year">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>Color</label>
<input value="" placeholder="Color" type="text" name="color">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>Class</label>
<input value="" placeholder="Stock, Modified, Highly Modified" type="text" name="class">
</fieldset>
</div>
<!--------------------
<div class="form-field">
<fieldset>
<label>Class</label>
<select class="form-field">
<option value="Select Class">Select Class</option>
<option value="Stock">Stock</option>
<option value="Modified">Modified</option>
<option value="Highly Modified">Highly Modified</option>
</select>
</fieldset>
</div>
------------------------->
<div class="form-field">
<fieldset>
<label>Last 4 digets of VIN</label>
<input value="" placeholder="Last 4 digets of VIN" type="text" name="vin">
</fieldset>
</div>
</form>
<form>
<h4>You</h4>
<div class="form-field">
<fieldset>
<label>Name</label>
<input value="" placeholder="Name" type="text" name="name">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>Address</label>
<input value="" placeholder="Address" type="text" name="address">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>City</label>
<input value="" placeholder="City" type="text" name="city">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>State</label>
<input value="" placeholder="State" type="text" name="state">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>Zip</label>
<input value="" placeholder="Zip" type="text" name="Zip">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>Email</label>
<input value="" placeholder="Email" type="text" name="email">
</fieldset>
</div>
</form>
<form>
<div class="form-button">
<input type="submit" value="Send"><input type="reset" value="Clear">
</div>
</form>
</section>
</div>
<body>
</body>
</html>
这是我的mail.php:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Form</title>
</head>
<?php
$year= $_POST['year'];
$color= $_POST['color'];
$class= $_POST['class'];
$vin= $_POST['vin'];
$name= $_POST['name'];
$address= $_POST['address'];
$city= $_POST['city'];
$state= $_POST['state'];
$zip= $_POST['zip'];
$email= $_POST['email'];
$formcontent="From: $name \n From: $city";
$recipient = "mjadecole17@yahoo.com";
$subject = "JatB Registration";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='index.html' style='text-decoration:none;color:#f15c25;'> Return Home</a>";
?>
<body>
</body>
</html>