0

I am new to PHP. while writing a simple email form using PHP I am getting error as

no element found

I am not sure why this error is present. Here is the PHP code.

<?php
$name       = @trim(stripslashes($_POST['name'])); 
$from       = @trim(stripslashes($_POST['email'])); 
$subject    = @trim(stripslashes($_POST['subject'])); 
$message    = @trim(stripslashes($_POST['message'])); 
$to         = 'helpdesk@hawkbirdsports.com';//replace with your email

$headers   = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();

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

die;
?>

Although this question has been already been asked before but still I am not able to find the right solution for my case.

shubham agrawal
  • 3,435
  • 6
  • 20
  • 31
  • Hi, please don't ever use `@`, it suppresses error messages and WILL make it harder to debug any issues, both for you and anyone trying to help you. - Also please include the full error message (and make sure error reporting is turned on) – Epodax Feb 14 '17 at 09:55
  • I am using PHP for the first time so I don't have much idea about @ .This is the only error I am getting. – shubham agrawal Feb 14 '17 at 10:00
  • are you running it locally? – Alive to die - Anant Feb 14 '17 at 10:01
  • Yes its running locally. – shubham agrawal Feb 14 '17 at 10:02
  • 1
    code enhancement:- https://eval.in/736589 . BTW try to check and use this solutions:- http://www.codexworld.com/how-to-send-email-from-localhost-in-php/ Or http://stackoverflow.com/a/13137606/4248328 OR http://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost – Alive to die - Anant Feb 14 '17 at 10:07

0 Answers0