html - Submit button is downloading the php instead of running it -


i'm trying make contact form website when press submit, php file downloaded instead of being ran. using chrome don't think should matter think there's syntax error i've messed around removing, adding , stuff , when there no syntax errors, still downloads file rather runs and, yes...it exact name of php file (sendemail.php)

html

<form name="contactform" method="post" action="sendemail.php">  <div class="contactheaders">name:</div>  <input type="text" name="name" class="contactboxes"/>  <div class="contactheaders">email:</div>  <input type="text" name="email" class="contactboxes"/>  <div class="contactheaders">message:</div>    <div style="width:100%">    <textarea name="message" maxlength="1000"></textarea>    </div>  <div style="width: 100%">  <input type="submit" class="submitbtn" value="submit">  </div> </form> 

php

if(isset($_post['email'])) {       $email_to = "email@domain.com";     $email_subject = "website contact";       function died($error) {          echo "we sorry, there error(s) found form submitted.";         echo "these errors appear below.<br /><br />";         echo $error."<br /><br />";         echo "please go , fix these errors.<br /><br />";         die();     }      // validation expected data exists     if(!isset($_post['name']) ||         !isset($_post['email']) ||         !isset($_post['message'])) {         died('sorry, there appears problem form submitted.');            }      $first_name = $_post['name']; // required     $last_name = $_post['email']; // required     $email_from = $_post['message']; // required      $error_message = "";     $email_exp = '/^[a-za-z0-9._%-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$/';   if(!preg_match($email_exp,$email)) {     $error_message .= 'the email address entered not appear valid.<br />';   }     $string_exp = "/^[a-za-z .'-]+$/";   if(!preg_match($string_exp,$name)) {     $error_message .= 'the first name entered not appear valid.<br />';   }    if(strlen($message) < 10) {     $error_message .= 'the message entered not appear valid.<br />';   }   if(strlen($error_message) > 0) {     died($error_message);   }      function clean_string($string) {       $bad = array("content-type","bcc:","to:","cc:","href");       return str_replace($bad,"",$string);     }       $name .= clean_string($name)."\n";     $email .= clean_string($email)."\n";     $message .= clean_string($message)."\n";   //email headers $headers = 'from: '.$email."\r\n". 'reply-to: '.$email."\r\n" . 'x-mailer: php/' . phpversion(); @mail($email_to, $email_subject, $message, $headers);   ?>  thank contacting me. in touch soon.  <?php  } ?> 

i can't find what's wrong!!!

if actual php soure code being downloaded, have configuration issues on webserver, won't go here.

i suggest remove @ infront of mail command though, since surpresses errors might having.

one of errors ie. surpressing fact yo u dont' have $message variable, considering fact code says: $email_from = $_post['message']; // required.

aside that: suggest read naming conventions concerning upper/lower case characters. makes debugging code quite bit easier. try http://framework.zend.com/manual/1.12/en/coding-standard.naming-conventions.html starters.

ps. have $message variable, empty.


Comments