Zach Cook
Zach Cook

Reputation: 614

PHPMailer not working correctly

I have a form that looks like this

<form action="send_attach_pear.php" type="POST" enctype="multipart/form-data">
<p>Name: <input type="text" name="name" id="name" /></p>
<input type="submit">
</form>

that sends information to the PHP file...

require 'class.phpmailer.php';

$name = $_POST['name'];

//Create a new PHPMailer instance
$mail = new PHPMailer();
$mail->setFrom('[email protected]', 'First Last');
$mail->addReplyTo('[email protected]', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'Zach Cook');
$mail->Subject = 'PHPMailer mail() test';
$mail->isHTML(true);
$msg = "This is a message from " . $name . ".";             
$mail->Body = $msg;

But for some reason "$name" is not showing up in the end email.

Do you know what is wrong?

Upvotes: 1

Views: 392

Answers (1)

Joke_Sense10
Joke_Sense10

Reputation: 5402

It is method = POST not type= POST

Here is the code:

<form action="send_attach_pear.php" method="POST" enctype="multipart/form-data">

Upvotes: 3

Related Questions