1.PHP
include'form.html'
form.html
<form action="email.php" method="post">
<input type="text" id="name" value="name" />
</form>
email.php
<?php
$name = $_POST['name'];
$email_message = "Name: $name ";
$sent = mail($email_to, $email_subject, $email_message);
if($sent) {
echo "success=yes";
} else {
echo "success=no";
}
include('success.html');
?>
错误:
Notice: Undefined index: name in C:\wamp\www\a\action.php on line 3
我也试过在form.html中创建全局变量但不能正常工作
答案 0 :(得分:2)
insert name =“name”表单的输入标记。像这样
<input type="text" id="name" value="name" name="name" />
name属性指定元素的名称。 name属性用于引用JavaScript中的元素,或在提交表单后引用表单数据。只有具有name属性的表单元素才会在提交表单时传递其值。