0
    <form action="" enctype="text/plain" method="post">
    <textarea name="link" style="margin-left: 0px; margin-right: 0px; width: 591px;" cols="1" rows="1" placeholder="Link"></textarea>

    <textarea name="username" style="margin-left: 0px; margin-right: 0px; width: 591px;" cols="1" rows="1" placeholder="Username"></textarea>

    <input type="submit" value="send" /></form>
<div style="color: red;">*Warning</div>
- Do not submit the request more than once if you do not want duplicate items.

<?php
$to      = 'admin@bdeas.com';
$subject = 'Market Purchase';
$message = htmlspecialchars($_POST['username']);
$message2 = htmlspecialchars($_POST['name'])
$headers = 'From: admin@bdeas.com' . "\r\n" .
    'Reply-To: admin@bdeas.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $message2, $headers);
?> 

I have this code here but I can't seem to get this code to send the mail. I have looked at the other posts but they don't help me as I need the form details to send the mail.

EDIT! Could you tell me if there is anything wrong in the code?

Jiung Song
  • 19
  • 5

3 Answers3

1

You can't have 2 messages like that. You need to join all parts of your final message into a string. If you want to include them both, do this:

<?php
    $to      = 'admin@bdeas.com';
    $subject = 'Market Purchase';
    $message = $_POST['username'] . '<br />' . $_POST['name'];
    $headers = 'From: admin@bdeas.com' . "\r\n" .
        'Reply-To: admin@bdeas.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();

    mail($to, $subject, $message, $headers);
?> 
Madness
  • 2,582
  • 3
  • 17
  • 26
1

try to change,

mail($to, $subject, $message, $message2, $headers);

to

mail($to, $subject, $message.' '.$message2, $headers);

Chandu9999
  • 1,876
  • 3
  • 11
  • 22
0

If you look at the manual page for the mail() function, you'll see its prototype takes 5 arguments, but they don't match what you're specifying here in your call to mail().

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

It looks like you're trying to send two messages at the same time, possibly? So your $message2 argument is getting sent as the $headers argument that mail() is expecting and your actual headers is getting sent as $additional_parameters.

If you meant to send it all as one message body you can concatenate the two strings into one. Otherwise you can call mail() multiple times.

N.B.

It's probably worth noting here that htmlspecialchars() doesn't help you unless you explicitly sent a Content-type header of text/html along with your email. Otherwise you're just making the message harder to read since the client will likely interpret it as plain/text by default.

Community
  • 1
  • 1
Sherif
  • 11,196
  • 3
  • 26
  • 54