1

私は最近、私のフリーランス クライアントのために Web サイトを開発しました。彼らの Web サイトには、お問い合わせフォームと見積もり依頼フォームがあります。

1 日 1 回、両方のフォームが送信され、指定された電子メール アドレスに電子メールで送信されます。ただし、送信されたフォームは明らかに実際のユーザーからのものではありません。これは、すべてのフィールドに数字の 1 が含まれているためです。たとえば、名前フィールドは Name:1、住所フィールドは Address:1 になります。番号 1 は、すべての入力テキスト フィールド、さらにはラジオおよびチェック ボックス フォーム フィールドで繰り返されます。

以下は、見積依頼フォームを送信するために使用している PHP ファイルのコピーです。

<?
$subject="Associated Sennott Contractors Request For Estimate From:".$_GET['firstname'];
$headers= "From: ".$_GET['email']."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
mail("email@gmail.com", $subject,  "
    <html>
        <head>
            <title>Associated Sennott Contractors Request For Estimate</title>
    </head>
<body>
    <p><strong>Associated Sennott Contractors Request For Estimate</strong></p>
    <p>
        First Name: ".$_GET['firstname']." <br />
        Last Name: ".$_GET['lastname']." <br />
        Company Name: ".$_GET['company']." <br />
        Address 1: ".$_GET['address1']." <br />
        Address 2: ".$_GET['address2']." <br />
        City: ".$_GET['city']." <br />
        State: ".$_GET['state']." <br />
        Zip: ".$_GET['zip']." <br />
        Phone: ".$_GET['phone']." <br />
        Fax: ".$_GET['fax']." <br />
        Email: ".$_GET['email']." <br /><br />

        <strong>Property Type:</strong><br />
        Residential Single Family: ".$_GET['singlefamily']." <br />
        Residential Multi-Family: ".$_GET['multifamily']." <br />
        Residential Out-Building : ".$_GET['outbuilding']." <br />
        Commercial Office: ".$_GET['commercial']." <br />
        Retail Store: ".$_GET['retail']." <br />
        Restaurant: ".$_GET['restaurant']." <br />
        Industrial Building: ".$_GET['industrial']." <br /><br />

        <strong>Requested Services:</strong><br />
        Fire, Water or Wind Damage Restoration: ".$_GET['restoration']." <br />
        Scope of Loss Estimate to Insurance Company: ".$_GET['scope']." <br />
        Smoke Odor Remediation: ".$_GET['smoke']." <br />
        Exterior Remodeling or Siding: ".$_GET['exterior']." <br />
        Interior Remodeling: ".$_GET['interior']." <br />
        Hardwood and Laminate Flooring: ".$_GET['flooring']." <br />
        Finish Carpentry: ".$_GET['carpentry']." <br />
        Demolition and Debris Removal: ".$_GET['demo']." <br />
        Exterior Decks, Patios and Fencing: ".$_GET['patio']." <br />
        Other: ".$_GET['other']." <br /><br />

        <strong>Additional Information:</strong><br />
        Message: ".$_GET['info']."
    </p>  
</body>
</html>" , $headers);
header( 'Location: thankyou.html' ) ;
?>

次のリンクから PHP コードを表示することもできます: http://sennottcontractors.com/home-repair-estimate/quote-code.html

次に、実際のフォームの HTML コードを以下に表示できます。

<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Request An Estimate Form</title>
<script type="text/javascript">
function formSubmit()
{
document.getElementById("estimate-form").submit();
}
</script>

</head>
<body>
<fieldset>
<legend><h3>Request a Home Restoration Estimate</h3></legend>
    <form id="estimate-form" name="estimate-form" target="_parent" method="get" action="quote.php" onsubmit='return formValidator()'>
        <p><strong>Contact Information</strong></p>
            <p>First Name: *<br />
            <input type="text" size="40" name="firstname" id="firstname" /></p>
            <p>Last Name: *<br />
            <input type="text" size="40" name="lastname" id="lastname" /></p>
            <p>Company Name:<br />
            <input type="text" size="40" name="company" id="company" /></p>
            <p>Address 1: *<br />
            <input type="text" size="40" name="address1" id="address1" /></p>
            <p>Address 2:<br />
            <input type="text" size="40" name="address2" id="address2" /></p>
            <p>City: *<br />
            <input type="text" size="30" name="city" id="city" /></p>
            <p>State: *<br />
            <input type="text" size="5" name="state" id="state" /></p>
            <p>Zip: *<br />
            <input type="text" size="10" name="zip" id="zip" /></p>
            <p>Phone: *<br />
            <input type="text" size="20" name="phone" id="phone" /></p>
            <p>Fax:<br />
            <input type="text" size="20" name="fax" id="fax" /></p>
            <p>Email: *<br />
            <input type="text" size="40" name="email" id="email" /></p>
        <br />
        <p><strong>Property Type</strong> *</p>
            <p><input type="checkbox" name="singlefamily" id="singlefamily"/> Residential Single Family</p>
            <p><input type="checkbox" name="multifamily" id="multifamily"/> Residential Multi-Family <em>(Condominium, apartment, town house, ect)</em></p>
            <p><input type="checkbox" name="outbuilding" id="outbuilding"/> Residential Out-Building <em>(Garage, shed, ect)</em></p>
            <p><input type="checkbox" name="commercial" id="commercial"/> Commercial Office</p>
            <p><input type="checkbox" name="retail" id="retail"/> Retail Store</p>
            <p><input type="checkbox" name="restaurant" id="restaurant"/> Restaurant</p>
            <p><input type="checkbox" name="industrial" id="industrial"/> Industrial Building</p>
        <br />
        <p><strong>Requested Services</strong> *</p>
            <p><input type="checkbox" name="restoration" id="restoration"/> Fire, Water or Wind Damage Restoration</p>
            <p><input type="checkbox" name="scope" id="scope"/> Scope of Loss Estimate to Insurance Company</p>
            <p><input type="checkbox" name="smoke" id="smoke"/> Smoke Odor Remediation</p>
            <p><input type="checkbox" name="exterior" id="exterior"/> Exterior Remodeling or Siding</p>
            <p><input type="checkbox" name="interior" id="interior"/> Interior Remodeling</p>
            <p><input type="checkbox" name="flooring" id="flooring"/> Hardwood and Laminate Flooring</p>
            <p><input type="checkbox" name="carpentry" id="carpentry"/> Finish Carpentry</p>
            <p><input type="checkbox" name="demo" id="demo"/> Demolition and Debris Removal</p>
            <p><input type="checkbox" name="patio" id="patio"/> Exterior Decks, Patios and Fencing</p>
            <p><input type="checkbox" name="other" id="other"/> Other</p>
        <br />
    <p><strong>Additional Information</strong><br />
    Please provide any information regarding details of your home restoration project or additional information to your requested services.</p>
    <p><textarea rows="10" cols="65" id="info" name="info"></textarea></p>
    <button type="submit" id="submit" onclick="formSubmit()">Submit</button>
    </form>
    <p>* Required Fields</p>
</fieldset>
</body>
</html>

上記の PHP ファイルとコードを使用する見積依頼フォームは、次のリンクから表示できます: http://sennottcontractors.com/home-repair-estimate/index.html

繰り返しになりますが、見積もり依頼フォームと連絡フォームの両方が 1 日 1 回、毎日送信され、すべてのフォーム フィールドに番号 1 が付けられています。

私の推測では、これは PHP ファイル自体の問題であるか、ホストされている Web サイトのサーバー側の問題である可能性があります。

助けてください!!!

4

3 に答える 3

2

フォームに技術的な問題はありません。問題の原因を自分で言いました:「...送信されたフォームは明らかに実際のユーザーからのものではありません...」。したがって、解決策はフォームをアンチボットにすることです。これを行う方法については、プロのWebマスターサイトでこの質問を参照してください。サイトをボット対策にしますか?

于 2012-08-07T16:52:40.120 に答える
2

この問題の一部は、フォームナンスまたは「トークン」を使用する必要があることです。

Form.php

<?php
session_start();

$_SESSION['token'] = md5(mt_rand() . unique_id('form', TRUE));

...

?>
<form>
<input type="hidden" value="<?php print $_SESSION['token']; ">
...
</form>

プロセス.php

<?php
session_start();

if($_SESSION['token'] !== $_POST['token'])
{
    die('They did not load the form!');
}

...

(validation)

...

$db->insert($record);
于 2012-08-07T17:01:18.377 に答える
1

検証を行っていません。あなたは何を期待していますか?

誰でもフォーム フィールドを取得して URL を作成し (POST ではなく GET を使用しているため)、必要に応じてそれを送信することができます。おそらく遭遇しているのは、ボットがフォームを乗っ取って、送信したい場所にメールを送信できるかどうかを判断しようとしているということです。

あなたがすべきことは、POST の使用に切り替え、$_SERVER['HTTP_REFERER']変数をチェックして、(少なくとも) フォームからのものであることを確認することです。CAPTCHA を使用することもできますが、それらはますます信頼できなくなりつつあります。これをさらに進めて、検証クラスを使用して、各フィールドのルールと、各フィールドに許可されるデータの種類を設定できます。

フォームは簡単に操作できるため、フォームの送信に整合性が必要な場合は、サーバー側で検証を行う必要があります。クライアント側の検証に問題はありませんが、データの整合性を確保するためではなく、ユーザー エクスペリエンスの目的でのみ使用してください。

于 2012-08-07T16:53:58.890 に答える