Nazar Serdyuk Nazar Serdyuk - 5 months ago 24x
PHP Question

How to insert input values to email body via php

I am developing a website and I can't get through this simple step:
Simply how to insert input values of order form to email body of the message I send via php code.

Finally it works. I just randomly changed the code until success. Here it is:

HTML code:

"<form name="order" method="post" action="email_script.php">
<input type="text" name="name" placeholder="Ваше Имя">
<input type="text" name="telephone" placeholder="Ваш Телефон">
<input type="submit" value="ОСТАВИТЬ ЗАЯВКУ">

PHP code:

$message .= $_POST["name"];
$message .= $_POST["telephone"];
$message = wordwrap($message,70);
mail("","Заказ Парня",$message);

What should I write instead of

$message .= "$_POST['name']\n";
$message .= "$_POST['telephone']"\n";

in order to fix the issue?

Exception stacktrace:

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE),
expecting identifier (T_STRING) or variable (T_VARIABLE) or number
(T_NUM_STRING) in /home4/nsaann/public_html/ on line 3


Change here

"<form name='order' method='post' action='email_script.php'>
  <input type='text' name='name' placeholder='Ваше Имя'>
  <input type='text' name='telephone' placeholder='Ваш Телефон'>
  <input type='submit' value='ОСТАВИТЬ ЗАЯВКУ'>

Also change here

$message = "";
$message .= "$_POST['name']\n";
$message .= "$_POST['telephone']\n";