-1

I have a form when a user enters data and submits, it will go to his mail, now I am having problem with keeping my logo in the mail, below is my php code for mail

<?php 
if(isset($_POST['submit'])){

    $to = "contact@bolstersolutions.com"; // this is your Email address
    $from = $_POST['name1']; // this is the sender's Email address
    $first_name = $_POST['name2'];
    $last_name = $_POST['email2'];
    $last_name1 = $_POST['number1'];
    $subject = "Referal";
    $subject2 = "Your Friend " . $from . " Has Referred You To Us For UK Process";
    $message = $from . " has refered the following student :" . "\n\n" . $first_name. "\n\n" .$last_name. "\n\n" .$last_name1;
    $message2 = "Your friend " . $from . " has referred you to Bolster Solutions for UK process. We will be more than happy to process your applications, thus helping you in achieving your goals to study MS in UK." . "\n\n" . "Feel free to go to the following url for more information or else you can also call us @ +91 9666999430 / 7661919191." . "\n\n" . "URL: https://consultancy.bolstersolutions.com/mail/" . "\n\n" . "Thanks and Regards." . "\n\n" . echo "<img src='https://consultancy.bolstersolutions.com/mail/assets/img/logo.png'>" ;

    $headers = "From:" . $from;
    $headers2 = "From: Bolster Solutions " . $to;
    mail($to,$subject,$message,$headers);
    mail($last_name,$subject2,$message2,$headers2); 
    
    
        }
?>

the following error is happening:

Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\xampp\htdocs\mail\index.php

Can anyone please help me with this, thanks in advance.

HP371
  • 860
  • 11
  • 24
Seep Sooo
  • 145
  • 11
  • Does this answer your question? [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – 04FS Dec 05 '19 at 10:48
  • Using `echo` in that position makes no sense. You are in a string context here already, so you need to keep concatenating parts, not try to sneak in an echo. – 04FS Dec 05 '19 at 10:49

2 Answers2

1
  1. Remove echo in $message2

  2. Set headers like this

    $headers = "From: " . strip_tags($_POST['req-email']) . "\r\n"; $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

  3. Then send : mail($last_name,$subject2,$message2,$headers);

Learner
  • 46
  • 4
0

There is a syntax error near: ..."\n\n" . echo "<img src.... Removing echo should solve it.