0

URL: http://medtransportcenter.com/medical-transportation/los-altos/ 最近フォームを更新してチェックボックスを追加しました。確認メールを送信するときに、チェックボックスがチェックされているかどうかを send-form.php スクリプトに認識させようとしています。いくつかの調査を行ったところ、次のコードがチェックされているかどうかをチェックするためのトリックを実行することがわかりました。しかし、フォームを挿入すると、フォームをテストするときに構文エラーが発生し続けました。以下のphpスクリプトとチェックボックスフィールド用の追加コードを含めました。これを手伝ってください。

私のフォーム全体のHTML:

<div class="form-box">
<!-- Form -->

<form id="proForm" action="send-form.php" method="post" >

<h2 style="text-align:center;">REQUEST INFO</h2>
        <h3 style="text-align:center;">FREE EXPERT ADVICE</h3>
<div class="form-content">
<!-- Form -->

<table cellpadding="0" cellspacing="0" border="0">

<!--tr>
<td class="field-full" colspan="2">
    <div class="label"><label for="www"><b>Your website URL</b></label></div>
    <input id="www" class="required defaultInvalidUrl url" maxlength="40" name="www" type="text" tabindex="2" value="http://" />
</td>
</tr-->
<tr>
<th class="label" align="right"><label for="nameis">Your name</label></td>:<td class="field">
  <input id="nameis" class="required defaultInvalidEmail nameis" maxlength="40" name="nameis" type="text" tabindex="2" value="Required" 
        onfocus="if (this.value == 'Required') {this.value = '';}"
        onblur="if (this.value == '') {this.value = 'Required';}" size="40" />
</td>
</tr>                                   
<tr>
<th class="label" align="right"><label for="email">E-mail</label></td>:<td class="field">
  <input id="email" class="required defaultInvalidEmail email" maxlength="40" name="email" type="text" tabindex="3" value="Required" 
        onfocus="if (this.value == 'Required') {this.value = '';}"
        onblur="if (this.value == '') {this.value = 'Required';}" size="40" />
</td>
</tr>   

<tr>
<th class="label" align="right"><label for="phone">Best Phone:</label></td>
<td class="field">
  <input id="phone" class="required defaultInvalidEmail phone" maxlength="40" name="phone" type="text" tabindex="4" value="Required" size="30" 
        onfocus="if (this.value == 'Required') {this.value = '';}"
        onblur="if (this.value == '') {this.value = 'Required';}" size="40" />
</td>
</tr>   

<tr>
<th class="label" align="right"><label for="bestime">
Best time to reach you:</label></td>
<td class="field">
  <input maxlength="40" size="30" name="bestime" type="text" tabindex="5" value="" />
</td>
</tr>

<tr>
<th class="label" align="right"><label for="phone">
Origin:</label></td>
<td class="field">
  <input maxlength="40" size="30" name="origin" type="text" tabindex="5" value="" />
</td>
</tr>

<tr>
<th class="label" align="right"><label for="phone">
Destination:</label></td>
<td class="field">
  <input maxlength="40" size="30" name="destination" type="text" tabindex="5" value="" />
</td>
</tr>


<tr>
<th class="label" align="right"><label for="msg">
Message:</label></td>
<td class="field">
  <textarea rows="3" cols="31" name="msg" tabindex="6"></textarea>
</td>
</tr>

<tr>
<th class="label"><label for="brochure">Request Brochures</label></td>
<td class="field">
  <input type="checkbox" name="brochure[]" value="Yes" />
</td>
</tr>       

<!--tr>
<td class="field-full" colspan="2">
    <div class="label"><label for="msg"><b>Other</b></label></div>
  <textarea rows="3" cols="30" name="msg" tabindex="9"></textarea>
</td>
</tr-->

</table>

<div class="terms">By clicking 'Send',<br/> you accept our <a onclick="showTerms()">Privacy Policy</a>. <br /><span style="font-size:14px;">Phone: 800-282-6878.</span></div>

<div class="btn-box"><input class="button1" type="submit" value="Send" tabindex="10" /></div>


<!-- END Form -->
</form> 
</div>

私のPHPスクリプト

<?php

//$www = '';    
$email = '';
$nameis = '';
$phone = '';
$bestime = '';
//$address = '';
$origin = '';
$destination = '';
$msg = '';
$brochure = '';

function getIp()
{if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
    $ip_address=$_SERVER['HTTP_X_FORWARDED_FOR'];
}

if (!isset($ip_address)){
        if (isset($_SERVER['REMOTE_ADDR'])) 
        $ip_address=$_SERVER['REMOTE_ADDR'];
}
return $ip_address;
}

if(isset($_POST['brochure'])){
$brochure_checked = $_POST['brochure'];} 
else {
$brochure_not_checked = $_POST['brochure'];
}


//taking info about date, IP and user agent

$timestamp = date("Y-m-d H:i:s");
$ip   = getIp();
$host = gethostbyaddr($ip); 
$user_agent = $_SERVER["HTTP_USER_AGENT"];


//taking the data from form 

//$www = addslashes(trim($_POST['www']));   
$email = addslashes(trim($_POST['email']));
$nameis = addslashes(trim($_POST['nameis']));
$phone = addslashes(trim($_POST['phone']));
$bestime = addslashes(trim($_POST['bestime']));
//$address = addslashes(trim($_POST['address']));
$origin = addslashes(trim($_POST['origin']));
$destination = addslashes(trim($_POST['destination']));
$msg = addslashes(trim($_POST['msg']));
$brochure = addslashes(trim($_POST['brochure']));




//preparing mail

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: quoted-printable\n";
$headers .= "From: $email\n";

$content = 'Name: '.$nameis.'<br>'.
'E-mail: '.$email.'<br>'.
'Phone: '.$phone.'<br>'.
'Message: '.$msg.'<br>'.
'Best Time to Call: '.$bestime.'<br>'.
'Origin: '.$origin.'<br>'.
'Destination: '.$destination.'<br>'.
'Requested Brochure: '.$brochure.'<br>'.
'Time: '.$timestamp.'<br>'.
'IP: '.$host.'<br>'.
'User agent: '.$user_agent;


//sending mail

mail("service@medtransportcenter.com","Los Altos, CA Landing Page Contact", $content, $headers);


?>
4

3 に答える 3