Jump to content

How to echo php variable inside automatic email


masnobi
Go to solution Solved by DavidAM,

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!';
}}
?>
Link to comment
Share on other sites

  • 2 years later...

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: 
Link to comment
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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.