我写信是为了在我的网站上创建一个联系表格,然后将信息发送到我的收件箱,但是它无论如何都不起作用。请看看我下面的代码(PHP 不是我的事),让我知道我哪里出错了。
这是 PHP 脚本:
<?php
$to = 'example@gmail.com';
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$tel = $_POST['tel'];
$project = $_POST['project'];
$range1 = $_POST['range1'];
$range2 = $_POST['range2'];
$body = <<<EMAIL
Hi, my name is $name.
I'd like to discuss the possibility of working together on a $project.
My budget for the project is £$range1 and I would like to complete the project within $range2 Month(s).
Additional Information:
$message
Regards, $name
<hr>
$name
$email
$tel
EMAIL;
$header = "From: $email";
if($_POST['send']){
mail($to, $subject, $body, $header);
$feedback = 'Thank you for your message, we will get back to you shortly.';
}
?>
这是 HTML 表单:
<form id="form_id" name="form_name" action="" method="post">
<div>
<input type="text" name="name" id="name" placeholder="Name" required/>
</div>
<div>
<input type="email" name="email" id="email" placeholder="Email" required/>
</div>
<div>
<input type="tel" name="tel" id="tel" placeholder="Phone" required/>
</div>
<div>
<select required id="project">
<option selected>Select type of project…</option>
<option value="Responsive Website">Responsive Web Design</option>
<option value="Graphic Design">Graphic Design</option>
<option value="Motion Graphics">Motion Graphics</option>
</select>
</div>
<div>
<label for="range1">Budget: </label>
<input type="range" name="range1" id="range1" min="400" max="2000" step="50" value="6" required onchange="rangevalue.value=value"><output id="rangevalue">400</output>
</div>
<div>
<label for="range2">Timeframe: </label>
<input type="range" name="range2" id="range2" min="1" max="12" step=".5" value="1" required onchange="rangevalue1.value=value"><output id="rangevalue1">1</output>
</div>
<div>
<label for="message">Additional Information: </label><br/>
<p>(Please use this space to tell us about your company, the main objectives of the proposed website and anything else you think might be useful)</p>
<textarea name="message" id="message" rows="5" cols="30" placeholder="Message" required></textarea>
</div>
<div>
<input type="submit" name="submit" value="submit" />
</div>
</form>
<p id="feedback"><?php echo $feedback; ?></p>
谢谢您的帮助。仅供参考,这可以通过联系表格 7(或类似插件)使用 WordPress 轻松实现。