-1

Here is my php,

    <?php
      $to = "jacob@codefarms.us, duma@codefarms.us";
      $subject = _POST['name'];
      $content = __POST['content'];
      $headers = _POST['email'];
      if (!$content === "") {
       mail($to,$subject,$content,$headers);
        }

     ?>

I get this error when I enter in information,

   Warning: Illegal string offset 'name' in 
/*****/*******/codefarms.us/contact.php on line 5

 Warning: Illegal string offset 'content' in 
 /*****/*******/codefarms.us/contact.php on line 6

 Warning: Illegal string offset 'email' in 
 /*****/*******/codefarms.us/contact.php on line 7

I don't understand why I am getting an error. I use hostgator to host my website.

  • 3
    _POST? RTM: http://php.net/manual/en/reserved.variables.post.php – Lawrence Cherone Feb 10 '18 at 19:07
  • 1
    I think it should be $_POST – Uchit Kumar Feb 10 '18 at 19:08
  • 1
    someone want to make that an answer? (it fixed it) – Mystic Coding Feb 10 '18 at 19:09
  • Just close it, This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting. – Lawrence Cherone Feb 10 '18 at 19:09

2 Answers2

0

You need to add an underscore "_" :

$name = $_POST['name'];

The method post should start with underscore "_"

Syscall
  • 19,327
  • 10
  • 37
  • 52
0

$_POST['name'] is the correct to access data in the post array.