masnobi Posted April 15, 2013 Share Posted April 15, 2013 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 https://forums.phpfreaks.com/topic/276955-how-to-echo-php-variable-inside-automatic-email/ Share on other sites More sharing options...
DavidAM Posted April 15, 2013 Share Posted April 15, 2013 $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. Link to comment https://forums.phpfreaks.com/topic/276955-how-to-echo-php-variable-inside-automatic-email/#findComment-1424779 Share on other sites More sharing options...
masnobi Posted April 15, 2013 Author Share Posted April 15, 2013 Thanks a lot dude, you are a star Link to comment https://forums.phpfreaks.com/topic/276955-how-to-echo-php-variable-inside-automatic-email/#findComment-1424788 Share on other sites More sharing options...
m4anm4 Posted May 23, 2015 Share Posted May 23, 2015 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 Link to comment https://forums.phpfreaks.com/topic/276955-how-to-echo-php-variable-inside-automatic-email/#findComment-1512512 Share on other sites More sharing options...
m4anm4 Posted May 23, 2015 Share Posted May 23, 2015 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 https://forums.phpfreaks.com/topic/276955-how-to-echo-php-variable-inside-automatic-email/#findComment-1512519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.