php - Custom Wordpress Page With Contact Form -


i trying create contact form wordpress site. fyi: client wants form static don't need able change in future. found form online. put custom page in wordpress. put mail.php file on server. when click submit hijacks me homepage/main theme page , message never sent. don't understand why takes me homage how fix this.

enter image description here

<table width="400" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td><strong>contact form </strong></td> </tr> </table> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="mail.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="16%">subject</td> <td width="2%">:</td> <td width="82%"><input name="subject" type="text" id="subject" size="50"></td> </tr> <tr> <td>detail</td> <td>:</td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> </tr> <tr> <td>name</td> <td>:</td> <td><input name="name" type="text" id="name" size="50"></td> </tr> <tr> <td>email</td> <td>:</td> <td><input name="customer_mail" type="text" id="customer_mail" size="50"></td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="submit" name="submit" value="submit"> <input type="reset" name="submit2" value="reset"></td> </tr> </table> </form> </td> </tr> </table> 

mail.php

<?php  // contact subject $subject ="$subject";   // details $message="$detail";  // mail of sender $mail_from="$customer_mail";   //  $header="from: $name <$mail_from>";  // enter email address $to ='someone@somewhere.com'; $mail=mail($to,$subject,$message,$header);  // check, if message sent email  // display message "we've recived information" if($mail){ echo "we've recived contact information"; } else { echo "error"; } ?> 

this simplest form, it's open injection..

$subject ="write here";  // details  $message = "write here";  // mail of sender  $mail_from = $_post['customer_mail'];  //  $header="fromfrom: yourname <yourdomain@yourdomain.con>";  // enter email address  $to ='$mail_from'; 

and put rest of code after it..

edit:

$subject = $_post['details'];  // mail of sender  $mail_from = $_post['customer_mail'];  //  $name = $_post['name'];  // details  $message = 'e-mail sent from: '.$mail_from.'\r\nname: '.$nane.'\r\n'.$_post['details'];  // enter email address  $to ='yourdomain@yourdomain.com';  $mail=mail($to,$subject,$message); 

final edit:

  <?  if (isset($_post['customer_mail'])) {    $subject = $_post['detail'];    // mail of sender    $mail_from = $_post['customer_mail'];    //    $name = $_post['name'];    // details    $message = 'e-mail sent from: '.$mail_from.'\r\nname: '.$name.'\r\n'.$_post['detail'];    // enter email address    $to ='yourdomain@yourdomain.com'; //edit    $mail=mail($to,$subject,$message);    echo "your mail has been sent";  } else {  ?>  <table width="400" border="0" align="center" cellpadding="3" cellspacing="1">    <tr>      <td><strong>contact form </strong></td>    </tr>  </table>   <table width="400" border="0" align="center" cellpadding="0" cellspacing="1">    <tr>      <td>       <form name="form1" method="post" action="<? echo $_server['php_self']; ?>">           <table width="100%" border="0" cellspacing="1" cellpadding="3">            <tr>                <td width="16%">subject</td>              <td width="2%">:</td>              <td width="82%">               <input name="subject" type="text" id="subject" size="50">             </td>            </tr>            <tr>              <td>detail</td>              <td>:</td>              <td>               <textarea name="detail" cols="50" rows="4" id="detail"></textarea>             </td>            </tr>            <tr>              <td>name</td>              <td>:</td>              <td>               <input name="name" type="text" id="name" size="50">             </td>            </tr>            <tr>              <td>email</td>              <td>:</td>              <td>               <input name="customer_mail" type="text" id="customer_mail" size="50">             </td>            </tr>            <tr>              <td>&nbsp;</td>              <td>&nbsp;</td>              <td>               <input type="submit" name="submit" value="submit">                <input type="reset" name="submit2" value="reset">             </td>            </tr>          </table>        </form>      </td>    </tr>  </table>   <? } ?> 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -