我一直试图通过网站表单提交来发送电子邮件。我已经测试过邮件是否有效,所以我对我做错了什么都不了解。请帮忙。
我已经被发送到stackoverflow上的其他PHP提交代码,它仍然无效。
PHP代码:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$input_342 = $_POST['input_342'];
$input_2152 = $_POST['input_2152'];
$from = 'From: *****.com';
$to = '*****@gmail.com'; // Email submissions are sent to this email
$subject = 'Customer Submission';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
HTML表单:
<form action="/includes/support_form.php" form id="support_form" method="POST">
<div class="form-group">
<label>Name</label>
<input id="name" class="form-control" type="text" name="name" required/>
</div>
<div class="form-group">
<label>Email</label>
<input id="email" class="form-control" type="email" name="email" required/>
</div>
<div class="form-group">
<label>Company Name</label>
<input id="company" class="form-control" type="text" name="company" required/>
</div>
<div class="form-group">
<label>Phone Number</label>
<input id="phone" class="form-control" type="text" name="phone" required/>
</div>
<div class="form-group">
<label>About Your Business</label><textarea id="message" class="form-control" rows="4" cols="50" name="message" type="text" required></textarea>
</div>
<div class="form-group">
<label>Please Contact me by</label>
</div>
<div class="radio">
<label><input type="radio" name="radioSetOne" value="option1" id="input_342"/>Email</label>
</div>
<div class="radio">
<label><input type="radio" name="radioSetOne" value="option2" id="input_2152"/>Phone</label>
</div>
<button class="bloc-button btn btn-lg btn-block btn-sea-green" name="submit" type="submit">
Submit
</button>
</form>
答案 0 :(得分:0)
您需要在所有输入(和按钮)上添加name="..."
你检查是否有“提交”。按钮中需要name="submit"
。
您可以使用网络监控(firebug,谷歌控制台)检查提交表单
id
和type
不发送php
你需要写出正确的类型...... "text"
或其他......