0

I have a form which get 2 fields: name and mail.

I want the submit button to send a mail to the email message with the name the user write to the mail that the user write. Here is my code:

PHP:

<html>
<body>

<?php
if(isset($_POST['submit'])){
    echo "in mail." . PHP_EOL;
    $username= $_POST['txtUsername'];
    echo $username. PHP_EOL;
    $email= $_POST['txtEmail']
    echo $email. PHP_EOL;
    $message = wordwrap($username, 70, "\r\n");
    echo $message . PHP_EOL;
    mail($email, 'lead', $message);
}
?>

</body>
</html> 

HTMl:

<!DOCTYPE html>
<html lang="he">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta charset="utf-8" />
<title>site</title>

</head>
<body  di

r="rtl">

    <form method="post" action="sendMail.php">
      <input type="text" name="txtUsername" placeholder="a" />
      <input type="text" name="txtEmail" placeholder="b" />
         <input type="submit" value="submit" name="submit">
    </form>

but I got Parse error: syntax error, unexpected T_ECHO in /home/a9816954/public_html/sendMail.php on line 10

What should be the problem? Is there a way to send the mail and stay in the corrent page using only php and html?

Thank you.

user1137582
  • 609
  • 1
  • 5
  • 13
  • 1
    Because you're missing a semicolon on the line above where you have `$email= $_POST['txtEmail']` – Sherif Oct 25 '15 at 10:42
  • Why do you use `PHP_EOL` in an email body? Doesn't really make sense in my eyes... Why do you want the emails to be formatted different depending on the operating system the server is based on? That would mean messages are displayed different each time! – arkascha Oct 25 '15 at 10:45
  • I'm not using PHP_EOL in an email body. I just echo it to the screen. I did it in order to debug. – user1137582 Oct 25 '15 at 10:51

2 Answers2

2

; after $email :

$email= $_POST['txtEmail'];
Sourabh Kumar Sharma
  • 2,864
  • 3
  • 25
  • 33
fico7489
  • 7,931
  • 7
  • 55
  • 89
0
$email= $_POST['txtEmail']

That line is missing an ; at the end of it

SpacePhoenix
  • 607
  • 1
  • 5
  • 15