我是PHP的新手,所以我确信这些东西很简单,我很遗憾。下面是我网站上的表格和用于抓取的PHP代码,它将正确的格式发送到我的电子邮件,但所有输入都是空的。
<form action="backyard/php/contact-form.php" id="contactForm" type="post">
<div class="row">
<div class="form-group">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span>
</span>
<input type="text" value="" data-msg-required="Please enter your name." maxlength="100" class="form-control" name="company" id="company" placeholder="Your Name">
</div>
</div>
<div class="col-md-6">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-map-marker" aria-hidden="true"></span>
</span>
<input type="text" value="" data-msg-required="Please enter your address." maxlength="100" class="form-control" name="name" id="name" placeholder="Enter Street Address, City, and Zip" required>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
</span>
<input type="email" value="" data-msg-required="Please enter your email address." data-msg-email="Please enter a valid email address." maxlength="100" class="form-control" name="email" id="email" placeholder="Email" required>
<div class="input-group">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<input type="submit" value="GET YOUR FREE REPORT" class="btn btn-primary btn-lg" data-loading-text="Loading...">
</div>
</div>
</form>
PHP:
<?php
$email = $_post['email'] ;
$name = $_post['name'] ;
$company = $_post['company'] ;
/* Set e-mail recipients */
$to = 'codyg@calculatedservices.ca';
// subject
$subject = "Message from " .$name. " - Calculated | Contact form";
// html message
$body = '
<html>
<head>
<style type="text/css">
body
{
font-family:sans-serif;
}
p
{
font-size:16px;
color:rgb(12,12,12);
}
h1
{
font-size:16px;
color:rgb(0,64,102);
}
.bg-color
{
background: rgb(245,245,245);
border-radius:8px;
}
.bg-color2
{
background:rgb(0,64,102);
color:white;font-size:16px;
border-radius:8px;
}
</style>
</head>
<body>
<table class="bg-color" border="0" cellspacing="0" cellpadding="8px" width="480" align="center">
<tr>
<td style="background:rgb(0,64,102);border-radius:8px;color:white;">
HELLO CALCULATED SERVICES
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td height="48" width="100%">
<p style="margin-top:20px;">Thank you from:</p>
<h1>'.$user_name.'</h1>
</td>
</tr>
<tr>
<td class="bg-color2">
Company: <b>'.$company.'</b><br>
Name: <b>'.$name.'</b><br>
Email: <b>'.$email.'</b><br>
</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= "From: " .$email. "\r\n";
// MAIL IT!
$success = mail($to, $subject, $body, $headers);
if($success)
{
$arrResult = array ('response'=>'success');
}
else
{
$arrResult = array ('response'=>'error');
}
header ("location: http://www.lestwarog.com")
&GT;