Notice: Undefined index $
This question already has an answer here:
通过使用isset
或!empty
:
<?php
$name = (isset($_POST['name']) ? $_POST['name'] : '');
$email = (isset($_POST['email']) ? $_POST['email'] : '');
$message = (isset($_POST['message']) ? $_POST['message'] : '');
?>
只需在代码中进行更改即可:
if (isset ($_POST['name'])) {
$name = $_POST['name'];
}
if (isset ($_POST['email'])) {
$email = $_POST['email'];
}
if (isset ($_POST['message'])) {
$message = $_POST['message'];
}
$from = 'From:';
$to = '86376@ict-idcollege.nl';
$subject = 'Hello';
if (isset ($_POST['human'])) {
$human = $_POST['human'];
}
place the code you have above inside a test block as follows
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
...
until the end of ?>
this is because when ever the page loads without the form submission. (because you have the control logic and display logic in the same file) it executes the code on the top.
链接地址: http://www.djcxy.com/p/69712.html上一篇: 在PHP中联系表单
下一篇: 注意:未定义索引$