Guest User

Untitled

a guest
Apr 26th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.09 KB | None | 0 0
  1. add_shortcode('eurocontact','custom_contact_form');
  2.  
  3.  
  4. function custom_contact_form(){
  5.  
  6. if (isset($_POST['w2lsubmit'])){
  7.  
  8.  
  9.    $destination="david@houseofquorum.com";
  10.    $message="First Name: ".$_POST['first_name']."\nLast Name: ".$_POST['last_name']."\nEmail: ".$_POST['email']."\nPhone: ".$_POST['phone']."\nCity: ".$_POST['city']."\nState: ".$_POST['state']."\nCountry: ".$_POST['country']."\nDescription: ".$_POST['description'];
  11.   $sender=$_POST['email'];
  12.    $subject="contact from\r".$sender;
  13.   $headers='From:'. $sender."\r\n".'Reply-To:'.$sender;
  14.  
  15.     mail($destination,$subject,$message,$headers);
  16.  
  17. ?>
  18.  
  19.  
  20. Thank you for message
  21.  
  22.     <?
  23. }
  24.  
  25.  
  26.     else{
  27.       custom_contact_form_html();
  28.     }
  29. }
  30.  
  31.  
  32.  
  33. function custom_contact_form_html(){
  34. ?>
  35.  
  36.     <script type="text/javascript">
  37.        function checkform(){
  38.  
  39.  
  40.            var x=document.forms["cform"]["first_name"].value;
  41.          if(x==""){
  42.              alert("Please Enter First Name");
  43.              return false;
  44.          }
  45.            var x=document.forms["cform"]["last_name"].value;
  46.            if(x==""){
  47.                alert("Please Enter Last Name");
  48.                return false;
  49.            }
  50.  
  51.  
  52.  
  53.            var x=document.forms["cform"]["email"].value;
  54.            var atpos=x.indexOf("@");
  55.            var dotpos=x.lastIndexOf(".");
  56.            if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
  57.            {
  58.                alert("Not a valid e-mail address");
  59.                return false;
  60.            }
  61.            var x=document.forms["cform"]["country"].value;
  62.            if(x==""){
  63.                alert("Please Enter Country");
  64.                return false;
  65.            }
  66.        }
  67.     </script>
  68.  
  69.  
  70.  
  71. <form method="post" class="w2llead sidebar" action="<? the_permalink() ?>" name="cform" onsubmit="return checkform();"  >
  72.     <label for="sf_first_name" class="w2llabel text">First name: *</label>
  73.     <input type="text" name="first_name" class="w2linput text" id="sf_first_name" value="">
  74.  
  75.     <label for="sf_last_name" class="w2llabel text">Last name: *</label>
  76.     <input type="text" name="last_name" class="w2linput text" id="sf_last_name" value="">
  77.  
  78.     <label for="sf_email" class="w2llabel text">Email: *</label>
  79.     <input type="text" name="email" class="w2linput text" id="sf_email" value="">
  80.  
  81.     <label for="sf_phone" class="w2llabel text">Phone:</label>
  82.     <input type="text" name="phone" class="w2linput text" id="sf_phone" value="">
  83.  
  84.     <label for="sf_city" class="w2llabel text">City:</label>
  85.     <input type="text" name="city" class="w2linput text" id="sf_city" value="">
  86.  
  87.     <label for="sf_state" class="w2llabel text">State:</label>
  88.     <input type="text" name="state" class="w2linput text" id="sf_state" value="">
  89.  
  90.     <label for="sf_country" class="w2llabel text">Country: *</label>
  91.     <input type="text" name="country" class="w2linput text" id="sf_country" value="">
  92.  
  93.     <label for="sf_description" class="w2llabel textarea">How can we help you?:</label>
  94.    
  95.     <textarea name="description" class="w2linput textarea" id="sf_description"></textarea>
  96.  
  97.     <input type="submit" value="Submit" class="w2linput submit" name="w2lsubmit">
  98. </form>
Add Comment
Please, Sign In to add comment