PHP contact form won't display correctly. The last bit of code doesn't register as code -


for whatever reason - , yes, new php - php code won't function correctly, also, won't register code. in screenshot can see displays plain text reason:

<div id="contactform">     <?php $action=$_request['action']; if ($action=="")    /* display contact form */     {     ?>     <form  action="" method="post" enctype="multipart/form-data">     <input type="hidden" name="action" value="submit">     name:<br>     <input name="name" type="text" value="" size="30"/><br>     email:<br>     <input name="email" type="text" value="" size="30"/><br>     message:<br>     <textarea name="message" rows="7" cols="30"></textarea><br>     <input type="submit" value="send email"/>     </form>  <?php     }  else                /* send submitted data */     {     $name=$_request['name'];     $email=$_request['email'];     $message=$_request['message'];     if (($name=="")||($email=="")||($message==""))         {         echo "all fields required, please fill form again.";         }     else     {                 $from="from: $name<$email>/r/n return-path: $email";         $subject="message sent using contact form";         mail("tono.nogueras@gmail.com", $subject, $message, $from);         echo "email sent!";         }     }  ?> </div> 

your mail headers incorrect 1 thing (see fixed code below), plus stated in comment noticed now, rename file .php instead of .html

html files can run php if tell apache so, may rename .php, it's lot simpler way.

use \r\n , not /r/n cause havoc , not render email addresses correctly , show (for example) bob<email@example.com>/r/nret in from field.

change:

$from="from: $name<$email>/r/n return-path: $email"; 

to:

$from="from: $name<$email>\r\nreturn-path: $email\r\n"; 

having space between /r/n , return-path did not render correctly , server did not recognize email proper email address in having space in there.


edit

try this, see if you're still getting undefined index error:

sidenote: replace email@example.com own e-mail address.

<div id="contactform">     <?php if (!isset($_post['action']))    /* display contact form */     {     ?>     <form  action="" method="post" enctype="multipart/form-data">     <input type="hidden" name="action" value="submit">     name:<br>     <input name="name" type="text" value="" size="30"/><br>     email:<br>     <input name="email" type="text" value="" size="30"/><br>     message:<br>     <textarea name="message" rows="7" cols="30"></textarea><br>     <input type="submit" value="send email"/>     </form>  <?php     }  else                /* send submitted data */     {     $name=$_request['name'];     $email=$_request['email'];     $message=$_request['message'];     if (($name=="")||($email=="")||($message==""))         {         echo "all fields required, please fill form again.";         }     else     {                 $from="from: $name<$email>\r\nreturn-path: $email\r\n";         $subject="message sent using contact form";         mail("email@example.com", $subject, $message, $from);         echo "email sent!";         }     }  ?> </div> 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -