提交表格问题

时间:2018-08-21 13:33:29

标签: php form-submit

我对php和提交表单不太熟悉。https://photos.app.goo.gl/GpbWvks2Y3SjwmX58以前(由其他人设置)是将查询从网站发送到特定的电子邮件ID,但似乎无法正常运行。检查文件后,我发现.php文件已移至存档文件夹。将其移回“联系人文件夹”下,现在单击“提交”按钮后,将显示“ .php文件代码”。不知道如何解决。真的很感谢一些专家的帮助。非常感谢。

我尝试了以前提交者提供的所有不同解决方案,但似乎没有任何效果适合我。请帮忙。

HTML脚本

<script type="text/javascript">document.getElementById('spc').value = 
   '755fd9ccedf916b2cd08bb7be88691dd';</script>
      <form name="enquiry" method="post" action="infosemantic-enquiryform1.php" class="form" id="form">
      <p class="input_field">
        <label class="field">First Name:</label>
      <input name="name" type="text" class="name_box" id="name" value="" size="35"></p>

    <p class="input_field">
      <label class="field">Last Name:</label>
      <input name="lastname" type="text" class="name_box" id="lastname" value="" size="35"></p>

    <p class="input_field">
      <label class="field">Title:</label>
      <input name="title" type="text" class="name_box" id="title" value="" size="35"></p>

     <p class="input_field">
      <label class="field">Company:</label>
      <input value="" name="company" class="name_box" size="35" type="text"></p>

    <p class="input_field">
      <label class="field">E-mail Address:</label>
      <input name="email" type="text" class="name_box" id="email" value="" size="35"></p>

    <p class="input_field">
      <label class="field">Message:</label>
      <textarea name="Message" id="csinbr" cols="45" rows="5" class="name_box2" w></textarea>
      </p>



      <p class="btn"><input name="Subject" value="Enquiry from DSR Power" type="hidden"><input name="Submit" value="Submit " class="sbm" type="submit"> 
      <input name="Reset" value="Clear Form" class="sbm" type="reset">
      </p>
       <font face="Verdana" size="2">
      <font face="Verdana" size="2">
      <input name="form_name" value="rajforever2" type="hidden">
      </font>
      <input name="userid" value="webindia" type="hidden">
      </font> 
  </form>

php脚本

 <?php  
        $to='info@domainname.com';

            $subject='Request Form for Company';


            $message ="<html><body><table align='center' boarder='1' cellpadding='5' cellspacing='2'  style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;font-weight:bold;background-color:#CCCCFF;color:#000000;;border:double'>";

             $message .= "<tr><td align='left'><b> Name  </b></td><td>:</td><td>".$_POST['name']."</td></tr>";

             $message .= "<tr><td align='left'><b>Last Name </b></td><td>:</td><td>".$_POST['lastname']."</td></tr>";

             $message .= "<tr><td align='left'><b>Title  </b></td><td>:</td><td>".$_POST['title']."</td></tr>";


             $message .= "<tr><td align='left'><b>Company </b></td><td>:</td><td>".$_POST['company']."</td></tr>";

             $message .= "<tr><td align='left'><b>Email </b></td><td>:</td><td>".$_POST['email']."</td></tr>";

             $message .= "<tr><td align='left'><b>Message</b></td><td>:</td><td>".$_POST['Message']."</td></tr>";
            $message .="</table></body></html>";


            /*to avoid spam mails in contact form*/
            // Select if you want to check form for standard spam text
            $SpamCheck = "Y"; // Y or N
            $SpamReplaceText = "*content removed*";
            // Error message prited if spam form attack found
            $SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Malicious code content detected.
                                </font><br><b>Your IP Number of <b>".getenv("REMOTE_ADDR")."</b> has been logged.</b></p>";
            $name = $_POST['name']; 
            $email = $_POST['email']; 
            $msg = $_POST['comments'];
        if ($SpamCheck == "Y") {           
            // Check for Website URL's in the form input boxes as if we block website URLs from the form,
            // then this will stop the spammers wastignt ime sending emails
            if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();} 
            if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();} 
            if (preg_match("/http/i", "$msg")) {echo "$SpamErrorMessage"; exit();} 

            // Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer 
            $pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string 

            $name = preg_replace($pattern, "", $name); 
            $email = preg_replace($pattern, "", $email); 
            $msg = preg_replace($pattern, "", $msg); 

            // Check for the injected headers from the spammer attempt 
            // This will replace the injection attempt text with the string you have set in the above config section
            $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i"); 
            $email = preg_replace($find, "$SpamReplaceText", $email); 
            $name = preg_replace($find, "$SpamReplaceText", $name); 
            $msg = preg_replace($find, "$SpamReplaceText", $msg); 

            // Check to see if the fields contain any content we want to ban
            if(stristr($name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
            if(stristr($msg, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 

            // Do a check on the send email and subject text
             if(stristr($to, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
             if(stristr($subject, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
        }
            /*End*/

             $headers = "From: $_POST[email]"."\r\n";

              $headers .= 'Bcc:bharath@briofactors.com'."\r\n";

                $headers .='Content-type: text/html; charset=iso-8859-1; format=flowed\n';

                $headers .="MIME-Version: 1.0\n";

                $headers .="Content-Transfer-Encoding: 8bit\n";

                $headers .="X-Mailer: PHP\n";           

if(mail($to, $subject, $message, $headers))
{
header("location:thanks.html");
}
?>

0 个答案:

没有答案