0

I'm making a php form with intelligent fill. So it takes the name ($to) then matches it to a name in the conditional. After passing it through that it continues from that statement and changes the $toaddress to the one associated with the name entered in the $to field. Whenever I run this code, it says that my indexes are undefined specifically it says

Undefined index: name (line 15)Undefined index: name (line 17)Undefined index: from (line 20)Undefined index: message (line 22)I do not recognize this person

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 Answers0