Note that there are some explanatory texts on larger screens.

plurals
  1. POSubmit button is downloading the php instead of running it
    primarykey
    data
    text
    <p>I'm trying to make a contact form for my website but when I press submit, the php file is downloaded instead of being ran. I am using chrome but don't think that should matter I think there's a syntax error but I've messed around with removing, adding and stuff and even when there is no syntax errors, it still downloads the file rather than runs it And, yes...it is the exact name of the php file (SendEmail.php)</p> <p><strong>HTML</strong></p> <pre><code>&lt;form name="contactform" method="post" action="SendEmail.php"&gt; &lt;div class="ContactHeaders"&gt;Name:&lt;/div&gt; &lt;input type="text" name="Name" class="ContactBoxes"/&gt; &lt;div class="ContactHeaders"&gt;Email:&lt;/div&gt; &lt;input type="text" name="Email" class="ContactBoxes"/&gt; &lt;div class="ContactHeaders"&gt;Message:&lt;/div&gt; &lt;div style="width:100%"&gt; &lt;textarea name="Message" maxlength="1000"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div style="width: 100%"&gt; &lt;input type="submit" class="Submitbtn" value="Submit"&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p><strong>PHP</strong></p> <pre><code>if(isset($_POST['Email'])) { $email_to = "email@domain.com"; $email_subject = "Website Contact"; function died($error) { echo "We are very sorry, but there were error(s) found with the form you submitted."; echo "These errors appear below.&lt;br /&gt;&lt;br /&gt;"; echo $error."&lt;br /&gt;&lt;br /&gt;"; echo "Please go back and fix these errors.&lt;br /&gt;&lt;br /&gt;"; die(); } // validation expected data exists if(!isset($_POST['Name']) || !isset($_POST['Email']) || !isset($_POST['Message'])) { died('Sorry, but there appears to be a problem with the form you 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 you entered does not appear to be valid.&lt;br /&gt;'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$Name)) { $error_message .= 'The First Name you entered does not appear to be valid.&lt;br /&gt;'; } if(strlen($Message) &lt; 10) { $error_message .= 'The message you entered does not appear to be valid.&lt;br /&gt;'; } if(strlen($error_message) &gt; 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); ?&gt; Thank you for contacting me. I will be in touch with you very soon. &lt;?php } ?&gt; </code></pre> <p>I can't find what's wrong!!! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload