-1

Hey guys im so new to PHP and im still learing i made small website and made a conatct form and i need to get that infromation to my email I watched some you tube tutorials and did some coding and some erro is showng up.plz help me out.........

( ! ) Parse error: syntax error, unexpected 'mail' (T_STRING) in C:\wampp\www\contact\contact.php on line 21

<?php
if (isset($_POST['submit'])){
$to='w.anjanadep@gmail.com';
$subject ="Message from Astaqua.com";
$from = $_POST['email'];
$name=$_POST['name'];
$subject=$_POST['subject'];
$phone=$_POST['Phone'];
$message=$_POST['message'];


$message='name:'.$_POST['name'].'<br>'.
         'subject:'.$_POST['subject'].'<br>'.
         'Phone:'.$_POST['Phone'].'<br>'.
         'message:'.$_POST['message'];

$header ='From:{$email}\r\n'.
'Cc:astaquag@gmail.com\r\n'.
'Content-Type:text/html;'

mail=($to,$subject,$message, $header);
}
>?
  • Change `mail=(` to `mail(` – B001ᛦ Nov 11 '21 at 13:28
  • if mail is variable then use `$mail` but as @B001ᛦ said, I think mail is function then use `mail(...)`. – vee Nov 11 '21 at 13:29
  • You forgot the semi-colon right before `mail=`(or put it in the wrong spot since it's inside of the quotes), which has been pointed out is also incorrect – aynber Nov 11 '21 at 13:30

3 Answers3

1

Your semi-colon is inside your header string, and you are assigning mail instead of calling the function. Change the last couple of lines to this

$header ='From:{$email}\r\n'.
'Cc:astaquag@gmail.com\r\n'.
'Content-Type:text/html';

mail($to,$subject,$message, $header);

Normally when you have an error like

Parse error: syntax error, unexpected 'mail'

it means you forgot a semi-colon on the line before.

mark_b
  • 1,393
  • 10
  • 18
0

Current php think mail is a a constant. But mail would be a funktion then change your last line to: mail($to,$subject,$message, $header);

KrassVerpeilt
  • 437
  • 3
  • 10
0

Mail is a function not a variable - remove the =

It should be:

mail($to,$subject,$message, $header);
Tom
  • 1
  • 1