php - <textarea> Not sending via email -


i'm trying create simple email form client , cannot <textarea> send message. i've tried have found far , nothing working properly...
here code:

<h4>email al</h4> <table> <form name="contactform" id="contact" action="send_form_email.php" method="post">     <tr>     <td>     <label>name:</label>     <input type="text" name="name">     </td>     <td>     <label>email address:</label>     <input type="email" name="email">     </td>     </tr>     <tr>     <td colspan="2">     <label>website (if available):</label>     <input type="text" name="website">     </td>     </tr>     <tr>     <td colspan="2">     <label>your message:</label></br>     <textarea for="" name="information" width="100%" rows="10" form="contactform"></textarea>     </td>     </tr>     <tr>     <td colspan="2">     <input type="submit" value="send message">     </td>     </tr> </form> </table> 

that form in index.php file, below email send-email.php

<?php   $name = $_post['name'];   $email = $_post['email'];   $website = $_post['website'];   $message = $_post['information'];      $email_from = 'myemail@gmail.com';      $email_subject = $name . " has sent message!";      $email_body = "you have received new message " . $name . " via website!\n".                             "name:\n $name\n".                             "email:\n $email\n".                             "website:\n $website\n".                             "message:\n $message\n".      $to = "clientemail@gmail.com";    $headers = "from: $email_from \r\n";    $headers .= "reply-to: $visitor_email \r\n";    mail($to,$email_subject,$email_body,$headers);   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;     } }  if(isinjected($visitor_email)) {     echo "bad email value!";     exit; } ?> <?php header("location: /formsubmitted.php"); /* redirect browser */ exit(); ?> 

if has clue why malfunctioning love know well! 1 of first message/email php functions i've created myself develop wordpress, install plugin client. in advanced help!

that's because of line: (consult footnote)

"message:\n $message\n". 

you have dot instead of (closing) semi-colon ;

edit: need remove form="contactform" <textarea>. upon testing, did not show in mail when used it.

and error reporting have told it.

being:

notice: undefined index: information (line 8)

and

notice: undefined variable: visitor_email (line 26 , 55)

in both:

$headers .= "reply-to: $visitor_email \r\n"; 

and

if(isinjected($visitor_email)) 

$visitor_email undefined in code. should have used $email instead instances of $visitor_email.

then have for="" doesn't appear valid syntax in <textarea...

that for="" ambiguous.

ref: https://developer.mozilla.org/en/docs/web/html/element/textarea

you should check empty fields conditional !empty().


footnote:

after more intensive testing, , in regards dot mentioned above, must state following:

strangely enough, php sees being valid syntax, there semi-colon in , included @ end here $to = "clientemail@gmail.com";

what still send mail, but include in email, not included in $email_body variable body.

therefore, first part of answer right extent, form="contactform" being major culprit here.

  • you may have meant use id id="contactform" or class class="contactform". both valid used , include in mail.

however, won't able use name="contactform" since <form> holds named attribute.

  • both name , id attributes (meant be) unique.

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -