Jump to content

Archived

This topic is now archived and is closed to further replies.

masnobi

How to echo php variable inside automatic email

Recommended Posts

Hi all, 

I want to echo two variables inside the body of automatic email. i am trying to get those two variables from the form that customer just submitted. i am posting my code below, please help ASAP. Thanks in advance

<?php
if(isset($_POST['button_pressed']))
{
$to=$Email;
$subject='Hi There!!';
$body='Hi'; $Title . '' . $Surname; ', 
This is a demo email sent using PHP on XAMPP';

if (mail($to,$subject,$body)){
 echo 'Mail sent successfully!';
}

else{
 echo 'Mail not sent!';
}}
?>

Share this post


Link to post
Share on other sites

 

$body='Hi'; $Title . '' . $Surname; ', 
This is a demo email sent using PHP on XAMPP';

 

That first semi-colon (after "Hi") should be a . (dot), for concatenation.

Share this post


Link to post
Share on other sites

Hello to everyone, is too late to ask you all a suggestion about this topic?

I need an help to generate an automatic answer to an email once completed the form, I have wrote only this little part

 

<form action="source_example1.php" method="post">

<label>Name: <input type="text" name="name" />
</label><br />
<label>Surname: <input type="text" name="surname" />
</label><br />
<input type="submit" value="Go" />
</form>
 
<?php
$firstname = $_POST ['name'];
$lastname = $_POST ['surname'];
echo "Thanks mate, $firstname $lastname!";
?>
 
 
Now, how send an email to me or someone else with that echo answer?
 
Thanking you all
Regards  :confused: 

Share this post


Link to post
Share on other sites

This is the original working robot

 

<form action="sorgente_esempio1.php" method="post">
<label>Nome: <input type="text" name="nome" />
</label><br />
<label>Cognome: <input type="text" name="cognome" />
</label><br />
<input type="submit" value="Vai" />
</form>
 
<?php
$firstname = $_POST ['nome'];
$lastname = $_POST ['cognome'];
echo "Thanks mate, $firstname $lastname!";
?>
 
Please help!

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.