php - Issue with POST method for form email submission -


i have created html form using following code (in haml):

%form#cform{method: 'post', name:'contactform', action: 'formemail.php'}   %input{type:'text', name: 'name'} name / business:   %input{type: 'text', name:'email'} email:   %textarea{name: 'message'} message:   %input{type:'submit', value:'send form'} 

here php file (formemail.php):

<?php  header('content-type: text/html; charset=utf-8');  if(!isset($_post['submit'])) {     //this page should not accessed directly. need submit form. echo "error; need submit form!"; } $name = $_post['name']; $visitor_email = $_post['email']; $message = $_post['message'];  //validate first if(empty($name)||empty($visitor_email))  {     echo "name , email mandatory!";     exit; }  if(isinjected($visitor_email)) {     echo "bad email value!";     exit; }  $email_from = 'david.w.martin@me.com'; $email_subject = "new form submission"; $email_body = "you have received new message user $name.\n".     "here message:\n $message".  $to = "david.w.martin@me.com"; $headers = "from: $email_from \r\n"; $headers .= "reply-to: $visitor_email \r\n"; //send email! mail($to,$email_subject,$email_body,$headers); //done. redirect thank-you page. header('location: thank-you.html');   // function validate against email injection attempts function isinjected($str) {   $injections = array('(\n+)',               '(\r+)',               '(\t+)',               '(%0a+)',               '(%0d+)',               '(%08+)',               '(%09+)'           );   $inject = join('|', $injections);   $inject = "/$inject/i";   if(preg_match($inject,$str))     {     return true;   }   else     {     return false;   } }  ?> 

when click "submit" receive following error in console:

post http://localhost:9000/formemail.php [http/1.1 404 not found 0ms] 

and following message appears in browser:

cannot post /formemail.php 

i can, however, access file directly (by inputting url browser).

the form located inside modal popup window (included in zurb foundation framework).

i lost, please help!!

try put http://localhost:9000/formemail.php action attribute. maybe port gets ignored , tries reach http://localhost/formemail.php of course 404.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -