dqzg62440 2018-08-29 14:50
浏览 25

表格提交代码检查

The Contact page which has form submission, https://photos.app.goo.gl/GpbWvks2Y3SjwmX58 is not being executed. I tried various solutions from other questions that's already been asked but had no luck. The .php file is in the Contacts folder along with the Contacts/index.html page. Some expert help would be much appreciated.

Here's the Javascript on the HTML page.

<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>
</div>


$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 = '/(;|\||`|>|<|&|^|"|'."
||'".'|{|}|[|]|\)|\()/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 = ["/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]"."
";
$headers .= 'Bcc:bharath@briofactors.com'."
";
$headers .= 'Content-type: text/html; charset=iso-8859-1; format=flowed
';
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Transfer-Encoding: 8bit
";
$headers .= "X-Mailer: PHP
";

if (mail($to, $subject, $message, $headers)) {
    header("location:thanks.html");
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染