输入显示为未定义的索引

时间:2016-03-29 00:55:09

标签: php html forms email conditional

我正在制作带有智能填充的php表单。所以它取名字($ to)然后将它匹配条件中的名称。在传递之后,它继续从该语句继续并将$ toaddress更改为与$ to字段中输入的名称相关联的那个。每当我运行这段代码时,它都会说我的索引是未定义的,具体说是

  

未定义索引:名称(第15行)未定义索引:名称(第17行)未定义索引:from(第20行)未定义索引:消息(第22行)我不认识此人

enter code here<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
    <form action="success.php" method="get">
        Name: <input type="text" name="name"><br>
        Email: <input type="text" name="from"><br>
        To: <input type="text" name="to"><br>
        Message: <input type="text" name="message">
        <input type="submit">
    </form>
    <?php  

    $name=htmlspecialchars($_POST['name']);
    $name=trim($name);
    $to=htmlspecialchars($_POST["name"]);
    $to=trim($to);
    $to=ucfirst($to);
    $from=htmlspecialchars($_POST['from']);
    $from=trim($from);
    $message=htmlspecialchars($_POST['message']);
    $message=trim($message);
    $toaddress='merrimack.scioly@gmail.com';
    $subject= $name . ': Has a question for you';
    $mailcontent= 'Team Member: ' .$name. "\n"
                  .'Email: ' .$from. "\n"
                  .'Message: '.$message. "\n";
    $fromaddress= 'From: merrimack.scioly@gmail.com';
    mail($toaddress, $subject, $message);   
 if (strstr($to, 'Andrew Pitten')) {
 $toaddress='jdoe@gmail.com';
 }
 elseif (strstr($to, 'Anna Correia')) {
    $toaddress='jdoe@gmail.com';
 }
elseif (strstr($to, 'Bryanna Bergevin')) {
    $toaddress='jdoe@gmail.com';
 }
 elseif (strstr($to, 'Caroline Pitten')) {
    $toaddress='jdoe@gmail.com';
}
elseif (strstr($to, 'Jason Provencher')) {
    $toaddress='jdoen@gmail.com';
}
elseif (strstr($to, 'Jordan Provencher')) {
    $toaddress='jdoen@gmail.com';
}
elseif (strstr($to, 'Ryan Bobbit')) {
    $toaddress='jdoe@gmail.com';
}
elseif (strstr($to, 'Sean Sylvester')) {
    $toaddress='jdoe@gmail.com';
}
elseif (strstr($to, 'Max Goddard')) {
    $toaddress='jdoe@gmail.com';
}
elseif (strstr($to, 'Davis')) {
    $toaddress='jdoe@merrimack.k12.nh.us';
}
elseif (strstr($to, 'Mr Davis')) {
    $toaddress='jdoe@merrimack.k12.nh.us';
}
elseif (strstr($to, 'Corliss')) {
    $toaddress='jdoe@gmail.com';
}
else echo "I do not recognize this person";
#nl2br somehwere
    ?>
</body>

0 个答案:

没有答案