douyaju4259 2014-03-21 07:26
浏览 58

这个表格给我一个错误“FAILED TO SEND”

The code of the contact form below gives me an error FORM SENDING FAILED.
Can you please help me resolve the issue?The code of the contact form below gives me an error FORM SENDING FAILED.
Can you please help me resolve the issue?The code of the contact form below gives me an error FORM SENDING FAILED.
Can you please help me resolve the issue?

    <form id="contactform" method="post" action="$_SELF">
        <label class="hide" for="author">Full Name</label> 
        <input class="input-fields" id="author" name="name" type="text" placeholder="Full Name" value="" required autofocus />

        <label class="hide" for="email">Email</label> 
        <input class="input-fields" id="email" name="email" type="text" placeholder="Email Address" value="" autofocus />

        <label class="hide" for="email">Mobile No</label> 
        <input class="input-fields" id="email" name="phone_no" type="text" placeholder="Mobile No" value="" autofocus />

        <label class="hide" for="author">Company</label> 
        <input class="input-fields" id="author" name="company" type="text" placeholder="Company" value="" required autofocus />

        <label class="hide" for="select_category">Select a Industry:</label> 
        <span id="select_group" class="select-group">
            <select name="vehicle">
                <option value="General" >Select a Industry:</option>
                <option value="General" >Health Centres Hospitals</option>
                <option value="Sales" >Tradeshows Conferences</option>
                <option value="Support" >Fast Foods and Restaurants</option>
                <option value="Support" >Night CLub, Bars and Disos</option>
                <option value="Support" >Banks , Rent Estate</option>
                <option value="Support" >Educational Institute</option>
                <option value="Support" >Recreational Facilities</option>
                <option value="Support" >Malls,Luxury Retail and Store Windows</option>
            </select>
        </span>

        <label class="hide" for="subject_title">Solutions</label> 
        <input class="input-fields" id="subject_title" name="solution" type="text" placeholder="Solutions" value="" autofocus />

        <label class="hide" for="author">Require</label> 
        <input class="input-fields" id="author" name="require" type="text" placeholder="Require" value="" required autofocus />

        <label class="hide" for="comment">Message</label> 
        <textarea id="comment" class="input-fields" placeholder="Message" name="message" cols="40" rows="200"></textarea>
        <span class="form_response">
                                           <ul id="errors" class="">
                                                    <li id="info">There were some problems with your form submission:</li>
                                           </ul>
                                                <p id="success" class="">Thanks for your message! We will get back to you ASAP!</p>
                                    </span>
        <input name="submit" type="submit" id="submit-contact-info" class="contact-info-submit form-submit-button span2" value="Send message">
                </form>
                          </div>
                </div>
            </article>
        </main>
  </div>


 <?php
         //If the form is submitted
        echo "hello";
           if(isset($_REQUEST['submit'])) 
           {
             $message = $_POST['message'];
           }                                     
                   //Check to make sure that the exit date field is not empty
             if(trim($_POST['vehicle']) == '') {
               $hasError = true;
             } else {
               $vehicle = trim($_POST['vehicle']);
             }
         //Check to make sure that the exit date field is not empty
             if(trim($_POST['require']) == '') {
               $hasError = true;
             } else {
               $require = trim($_POST['require']);
             }
         //Check to make sure that the exit date field is not empty
             if(trim($_POST['solution']) == '') {
               $hasError = true;
             } else {
               $solution = trim($_POST['solution']);
             }

           //Check to make sure that the name field is not empty
             if(trim($_POST['name']) == '') {
               $hasError = true;
             } else {
               $name = trim($_POST['name']);
             }

           //Check to make sure sure that a valid email address is submitted
             if(trim($_POST['email']) == '')  {
               $hasError = true;
             } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
               $hasError = true;
             } else {
               $email = trim($_POST['email']);
             }
           //Check to make sure that the mobile no field is not empty
             if(trim($_POST['phone_no']) == '') {
               $hasError = true;
             } else {
               $phone_no = trim($_POST['phone_no']);
             }

             //If there is no error, send the email
    if(!isset($hasError)) 
      {
               $emailTo = "sahil7771@gmail.com"; //Put your own email address here
               $body = "Name: $name 

Email: $email 

Mobile No: $phone_no 

 Your Industry: $vehicle 
\
              

 Your Requirement: $require 

 Your Solution: $solution 

 
              

 Message : $message 
              

Please Contact $name  on $phone_no
 
 /====================================/ ";
               $headers = 'From: Touch Active  <'. $emailTo .'>' . "
" . 'Reply-To: ' . $email; 


                                              if(mail($emailTo, 'Mail From Touch Active', $body, $headers))
                                              { //Replace Your Website Subject
                                                $response=1;
                                                $emailSent = true; 


                                              ?> 

               <div id="responsive-container" ><p>Thanks For Messaging Us You Will Shortly Expect Our Assistance ( With In 24hrs ).</p></div>

               <?php
               }
                else
               {
                 ?>
                 <div id="page-title"><h2>Failed To Sent</h2></div>
                 <?php
                 $response=0;
               }
         }

   ?>
  • 写回答

2条回答 默认 最新

  • dshw124502 2014-03-21 07:44
    关注

    Change in form action="$_SELF" to action="$_SERVER['PHP_SELF']", because there isn't constant like $_SELF.

    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据