-1

So I'm learning my way through PHP and I followed a tutorial exactly for creating a form that uses php to send me an email through the server I'm using but its not working. I checked around to see if my question has been answered in a way I can understand but I came up empty. I probably just don't know enough about this language but I want to get this feature up and running at least so I can have a way to receive emails without giving out mine. please don't suggest other options I want to fix this code.

I have checked to make sure I followed the tutorial correctly and I have. I am missing something key here I just don't know what.

<?php
 if (ifset()$_POST['submit']) {
   $name = $_POST['name'];
   $subject = $_POST['subject'];
   $mailFrom = $_POST['mail'];
   $message = $_POST['message'];

   $mailTo = "https://formspree.io/xoqaovaa"
   $headers = "From: ".$mailFrom;
   $txt = "you have recieved an E-mail from ".$name.".\n\n".$message;


   mail($mailTo, $subject, $txt, $headers);
   header("Location: contactForm.php?mailsend");

 }
 ?>

I expected my contact form to accept inputs from the user in various fields and send those in a message though my server to my email routing service when the user clicks submit button.

what happens when I go to the page is this error: Parse error: syntax error, unexpected '$_POST' (T_VARIABLE) in /storage/ssd5/051/11462051/public_html/PHP/master.php on line 2

Ethan
  • 3
  • 3

1 Answers1

0

The name of the function is isset(), not ifset(). And you have the ) in the wrong place. It should be:

 if (isset($_POST['submit'])) {

And then you are missing the terminating ; at this line:

$mailTo = "https://formspree.io/xoqaovaa"
AbraCadaver
  • 78,200
  • 7
  • 66
  • 87
Barmar
  • 741,623
  • 53
  • 500
  • 612