php/html 缺少表单主题行
php/html form subject line missing
使用 php 代码将表单输入发送到电子邮件时出现问题。
<?php
$emailTo="testing_testing@gmail.com";
$subject = $POST_['username'];
$content = $_POST['course'] . $_POST['message'] . $_POST['tel'];
$headers = "From: ".$_POST['email'];
mail($emailTo, $subject, $content, $headers);
?>
HTML 表单代码:
<form method="post">
<input id="username" type="text" name="username" placeholder="Name" required> </br>
<input id="tel" type = "tel" name="tel" placeholder="Phone no." required></br>
<input id="email" type="email" name="email" placeholder="Email id" required></br>
<input list="course" name="course">
<datalist id="course">
<option value="IELTS">
<option value="English Speaking">
<option value="Computers">
<option value="Accounting">
<option value="Fashion Designing">
<option value="Hospitality and Tourism">
<option value="General Enquiry">
</datalist>
<textarea id="message" name="message" rows="10" cols="30" placeholder="Any Message !"></textarea>
<INPUT id="submit" type="submit" value="Submit">
</form>
输出:
此代码没有像它所说的那样设置主题字段 - nosubject。在 php 代码中,我将用户名的值指定为主题字段。
问题是您对 $subject
变量的声明:
$subject = $POST_['username'];
应该是
$subject = $_POST['username'];
希望这对您有所帮助:)
使用 php 代码将表单输入发送到电子邮件时出现问题。
<?php
$emailTo="testing_testing@gmail.com";
$subject = $POST_['username'];
$content = $_POST['course'] . $_POST['message'] . $_POST['tel'];
$headers = "From: ".$_POST['email'];
mail($emailTo, $subject, $content, $headers);
?>
HTML 表单代码:
<form method="post">
<input id="username" type="text" name="username" placeholder="Name" required> </br>
<input id="tel" type = "tel" name="tel" placeholder="Phone no." required></br>
<input id="email" type="email" name="email" placeholder="Email id" required></br>
<input list="course" name="course">
<datalist id="course">
<option value="IELTS">
<option value="English Speaking">
<option value="Computers">
<option value="Accounting">
<option value="Fashion Designing">
<option value="Hospitality and Tourism">
<option value="General Enquiry">
</datalist>
<textarea id="message" name="message" rows="10" cols="30" placeholder="Any Message !"></textarea>
<INPUT id="submit" type="submit" value="Submit">
</form>
输出:
此代码没有像它所说的那样设置主题字段 - nosubject。在 php 代码中,我将用户名的值指定为主题字段。
问题是您对 $subject
变量的声明:
$subject = $POST_['username'];
应该是
$subject = $_POST['username'];
希望这对您有所帮助:)