php - Custom wordpress contact form -


i trying make custom wordpress contact form. i've got far:

my function contact form itself:

<?php if( isset( $_post['submitted'] ) ) {   //response generation function    $response = "";    //function generate response   function my_contact_form_generate_response($type, $message){      global $response;      if($type == "success") $response = "<div class='success'>{$message}</div>";     else $response = "<div class='error'>{$message}</div>";    }    //response messages   $not_human       = "human verification incorrect.";   $missing_content = "please supply information.";   $email_invalid   = "email address invalid.";   $message_unsent  = "message not sent. try again.";   $message_sent    = "thanks! message has been sent.";    //user posted variables   $name = $_post['message_name'];   $email = $_post['message_email'];   $message = $_post['message_text'];   $human = $_post['message_human'];    //php mailer variables   $to = get_option('admin_email');   $subject = "someone sent message ".get_bloginfo('name');   $headers = 'from: '. $email . "\r\n" .     'reply-to: ' . $email . "\r\n";    if(!$human == 0){     if($human != 2) my_contact_form_generate_response("error", $not_human); //not human!     else {        //validate email       if(!filter_var($email, filter_validate_email))         my_contact_form_generate_response("error", $email_invalid);       else //email valid       {         //validate presence of name , message         if(empty($name) || empty($message)){           my_contact_form_generate_response("error", $missing_content);         }         else //ready go!         {           $sent = wp_mail($to, $subject, strip_tags($message), $headers);           if($sent) my_contact_form_generate_response("success", $message_sent); //message sent!           else my_contact_form_generate_response("error", $message_unsent); //message wasn't sent         }       }     }   }   else if ($_post['submitted']) my_contact_form_generate_response("error", $missing_content); } ?> 

secondly:

<div id="respond">           <?php echo $response; ?>           <form action="<?php the_permalink(); ?>" method="post">             <p><label for="name">name: <span>*</span> <br><input type="text" name="message_name" value="<?php echo esc_attr($_post['message_name']); ?>"></label></p>             <p><label for="message_email">email: <span>*</span> <br><input type="text" name="message_email" value="<?php echo esc_attr($_post['message_email']); ?>"></label></p>             <p><label for="message_text">message: <span>*</span> <br><textarea type="text" name="message_text"><?php echo esc_textarea($_post['message_text']); ?></textarea></label></p>             <p><label for="message_human">human verification: <span>*</span> <br><input type="text" style="width: 60px;" name="message_human"> + 3 = 5</label></p>             <input type="hidden" name="submitted" value="1">             <p><input type="submit"></p>           </form>         </div> 

this works fine, it's quite basic. didn't want use plugin seem bloated , quite messy. maybe i've looked @ bad choices. anyway, wanted know if it's possible edit how message formatted when it's email admin. @ moment message no other information persons name, email..

am making bad choice using this?

it great format emails sent via form formatted like:

sender: joe blogs

email: joe@blogs.com

message: love you.

if it's fast, lightweight, , want (after work kinks out), that's great. can see being faster , less burdensome plugin.

my concern of more popular contact form plugins contact form 7 have been field-tested usability, exploits, etc., , have had code added handle these cases.

if you're rolling own, might (likely will?) hit something, , if end sending lot of spam due exploit in form, it's on you.

not discourage efforts -- , not can see wrong you've done! -- gut feeling.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -