我已经看到很多关于这种症状的问题,但没有一个答案似乎能解决我的问题。我收到这样的通知(其中15个,每个从表单传递的变量一个),结果是用户看到的页面是空白的。
注意:未定义的索引:第3行的C:\ Web Files \ www.iusc.org \ scripts \ send_form_email.php中的FirstName
然而,当我在Firefox中使用Firebug查看POST时,我看到变量(全部15个)已正确填充。
根据请求,我将包含所有这两个文件。这是HTML部分的大部分内容,我不允许发布它,它超出了大小限制:
<tr>
<td>
<FORM method="post" action="/scripts/send_form_email.php" name="BecomeForm" ENCTYPE="text/plain">
<table BORDER="0" CELLPADDING="3" CELLSPACING="0" WIDTH="520">
<tr>
<td>
<table border="0" cellPadding="0" cellSpacing="0" width="520">
<tr>
<td class="info" align="right" width="100"><font color="#cc0000">First Name:</font></td>
<td ALIGN="left" width="100">
<input type="text" SIZE="20" id="FirstName" name="FirstName" maxlength="30" value=""></td>
<td class="info" ALIGN="right" width="200" colspan="2"><font color="#cc0000">Last Name:</font></td>
<td ALIGN="left" width="100">
<input type="text" SIZE="20" id="LastName" name="LastName" maxlength="30" value=""></td>
</tr>
<tr>
<td class="info" align="right" width="100"><font color="#cc0000">eBay
User ID:</font></td>
<td ALIGN="left" width="100">
<input type="text" SIZE="20" id="UserID" name="UserID" maxlength="50" value=""></td>
<td class="info" ALIGN="right" width="200" colspan="2">APS Number:</td>
<td ALIGN="left" width="100">
<input type="text" SIZE="20" id="APSNumber" name="APSNumber" value=""></td>
</tr>
<tr>
<td class="info" ALIGN="right" Width="100"><font color="#cc0000">Street Address:</font></td>
<td Colspan="4" ALIGN="left" Width="450">
<input SIZE="40" id="Address1" name="Address1" maxlength="80" value="">
</td>
</tr>
<tr>
<td class="info" ALIGN="right" Width="100">Room/Floor/Apt#:</td>
<td Colspan="4" ALIGN="left" Width="450">
<input SIZE="40" id="Address2" name="Address2" maxlength="40" value="">
</td>
</tr>
<tr>
<td class="info" align="right" width="100"><font color="#cc0000">City:</font></td>
<td Colspan="4" ALIGN="left" width="180">
<input SIZE="40" id="City" name="City" maxlength="40" value=""></td>
</tr>
<tr>
<td class="info" ALIGN="right" width="100"><font color="#cc0000">State/Province:</font></td>
<td ALIGN="left" width="100">
<input id="State" name="State" maxlength="3" value="" size="20"></td>
<td class="info" ALIGN="right" width="200" colspan="2"><font color="#cc0000">Postal Code:</font></td>
<td ALIGN="left" width="100">
<input SIZE="10" id="PostalCode" name="PostalCode" value="" maxlength="12"></td>
</tr>
<tr>
<td class="info" ALIGN="right" width="100"><font color="#cc0000">Country:</font></td>
<td ALIGN="left" width="100" colspan="4">
<select id="Country" name="Country" size="1">
<option value="004">Afghanistan</option>
<option value="008">Albania</option>
<option value="012">Algeria</option>
<option value="016">American Samoa</option>
<option value="020">Andorra</option>
<option value="024">Angola</option>
<option value="660">Anguilla</option>
<option value="028">Antigua And Barbuda</option>
<option value="032">Argentina</option>
<option value="051">Armenia</option>
<option value="533">Aruba</option>
<option value="036">Australia</option>
<option value="040">Austria</option>
<option value="031">Azerbaijan</option>
<option value="044">Bahamas</option>
<option value="048">Bahrain</option>
<option value="050">Bangladesh</option>
<option value="052">Barbados</option>
<option value="112">Belarus</option>
<option value="056">Belgium</option>
<option value="084">Belize</option>
<option value="204">Benin</option>
<option value="060">Bermuda</option>
<option value="064">Bhutan</option>
<option value="068">Bolivia</option>
<option value="070">Bosnia and Herzegowina</option>
<option value="072">Botswana</option>
<option value="074">Bouvet Island</option>
<option value="076">Brazil</option>
<option value="086">British Indian Ocean Territory</option>
<option value="096">Brunei Darussalam</option>
<option value="100">Bulgaria</option>
<option value="854">Burkina Faso</option>
<option value="108">Burundi</option>
<option value="116">Cambodia</option>
<option value="120">Cameroon</option>
<option value="124">Canada</option>
<option value="132">Cape Verde</option>
<option value="136">Cayman Islands</option>
<option value="140">Central African Republic</option>
<option value="148">Chad</option>
<option value="152">Chile</option>
<option value="156">China</option>
<option value="162">Christmas Island</option>
<option value="166">Cocos (Keeling) Islands</option>
<option value="170">Colombia</option>
<option value="174">Comoros</option>
<option value="178">Congo</option>
<option value="180">Congo, The Democratic Republic Of The</option>
<option value="184">Cook Islands</option>
<option value="188">Costa Rica</option>
<option value="384">Cote D'ivoire</option>
<option value="191">Croatia (Local Name: Hrvatska)</option>
<option value="192">Cuba</option>
<option value="196">Cyprus</option>
<option value="203">Czech Republic</option>
<option value="208">Denmark</option>
<option value="262">Djibouti</option>
<option value="212">Dominica</option>
<option value="214">Dominican Republic</option>
<option value="626">East Timor</option>
<option value="218">Ecuador</option>
<option value="818">Egypt</option>
<option value="222">El Salvador</option>
<option value="226">Equatorial Guinea</option>
<option value="232">Eritrea</option>
<option value="233">Estonia</option>
<option value="231">Ethiopia</option>
<option value="238">Falkland Islands (Malvinas)</option>
<option value="234">Faroe Islands</option>
<option value="242">Fiji</option>
<option value="246">Finland</option>
<option value="250">France</option>
<option value="254">French Guiana</option>
<option value="258">French Polynesia</option>
<option value="260">French Southern Territories</option>
<option value="266">Gabon</option>
<option value="270">Gambia</option>
<option value="268">Georgia</option>
<option value="276">Germany</option>
<option value="288">Ghana</option>
<option value="292">Gibraltar</option>
<option value="300">Greece</option>
<option value="304">Greenland</option>
<option value="308">Grenada</option>
<option value="312">Guadeloupe</option>
<option value="316">Guam</option>
<option value="320">Guatemala</option>
<option value="324">Guinea</option>
<option value="624">Guinea-Bissau</option>
<option value="328">Guyana</option>
<option value="332">Haiti</option>
<option value="334">Heard and Mc Donald Islands</option>
<option value="336">Holy See (Vatican City State)</option>
<option value="340">Honduras</option>
<option value="344">Hong Kong</option>
<option value="348">Hungary</option>
<option value="352">Iceland</option>
<option value="356">India</option>
<option value="360">Indonesia</option>
<option value="364">Iran</option>
<option value="368">Iraq</option>
<option value="372">Ireland</option>
<option value="376">Israel</option>
<option value="380">Italy</option>
<option value="388">Jamaica</option>
<option value="392">Japan</option>
<option value="400">Jordan</option>
<option value="398">Kazakhstan</option>
<option value="404">Kenya</option>
<option value="296">Kiribati</option>
<option value="408">Korea, Democratic People's Republic Of</option>
<option value="410">Korea, Republic Of</option>
<option value="414">Kuwait</option>
<option value="417">Kyrgyzstan</option>
<option value="418">Lao People's Democratic Republic</option>
<option value="428">Latvia</option>
<option value="422">Lebanon</option>
<option value="426">Lesotho</option>
<option value="430">Liberia</option>
<option value="434">Libyan Arab Jamahiriya</option>
<option value="438">Liechtenstein</option>
<option value="440">Lithuania</option>
<option value="442">Luxembourg</option>
<option value="446">Macau</option>
<option value="807">Macedonia, The Former Yugoslav Republic Of</option>
<option value="450">Madagascar</option>
<option value="454">Malawi</option>
<option value="458">Malaysia</option>
<option value="462">Maldives</option>
<option value="466">Mali</option>
<option value="470">Malta</option>
<option value="584">Marshall Islands</option>
<option value="474">Martinique</option>
<option value="478">Mauritania</option>
<option value="480">Mauritius</option>
<option value="175">Mayotte</option>
<option value="484">Mexico</option>
<option value="583">Micronesia, Federated States Of</option>
<option value="498">Moldova, Republic Of</option>
<option value="492">Monaco</option>
<option value="496">Mongolia</option>
<option value="500">Montserrat</option>
<option value="504">Morocco</option>
<option value="508">Mozambique</option>
<option value="104">Myanmar</option>
<option value="516">Namibia</option>
<option value="520">Nauru</option>
<option value="524">Nepal</option>
<option value="528">Netherlands</option>
<option value="530">Netherlands Antilles</option>
<option value="540">New Caledonia</option>
<option value="554">New Zealand</option>
<option value="558">Nicaragua</option>
<option value="562">Niger</option>
<option value="566">Nigeria</option>
<option value="570">Niue</option>
<option value="574">Norfolk Island</option>
<option value="580">Northern Mariana Islands</option>
<option value="578">Norway</option>
<option value="512">Oman</option>
<option value="586">Pakistan</option>
<option value="585">Palau</option>
<option value="275">Palestinian Territory, Occupied</option>
<option value="591">Panama</option>
<option value="598">Papua New Guinea</option>
<option value="600">Paraguay</option>
<option value="604">Peru</option>
<option value="608">Philippines</option>
<option value="612">Pitcairn</option>
<option value="616">Poland</option>
<option value="620">Portugal</option>
<option value="630">Puerto Rico</option>
<option value="634">Qatar</option>
<option value="638">Reunion</option>
<option value="642">Romania</option>
<option value="643">Russian Federation</option>
<option value="646">Rwanda</option>
<option value="659">Saint Kitts And Nevis</option>
<option value="662">Saint Lucia</option>
<option value="670">Saint Vincent And The Grenadines</option>
<option value="882">Samoa</option>
<option value="674">San Marino</option>
<option value="678">Sao Tome And Principe</option>
<option value="682">Saudi Arabia</option>
<option value="686">Senegal</option>
<option value="690">Seychelles</option>
<option value="694">Sierra Leone</option>
<option value="702">Singapore</option>
<option value="703">Slovakia (Slovak Republic)</option>
<option value="705">Slovenia</option>
<option value="090">Solomon Islands</option>
<option value="706">Somalia</option>
<option value="710">South Africa</option>
<option value="239">South Georgia And The South Sandwich Islands</option>
<option value="724">Spain</option>
<option value="144">Sri Lanka</option>
<option value="654">St. Helena</option>
<option value="666">St. Pierre And Miquelon</option>
<option value="736">Sudan</option>
<option value="740">Suriname</option>
<option value="744">Svalbard And Jan Mayen Islands</option>
<option value="748">Swaziland</option>
<option value="752">Sweden</option>
<option value="756">Switzerland</option>
<option value="760">Syrian Arab Republic</option>
<option value="158">Taiwan, Province Of China</option>
<option value="762">Tajikistan</option>
<option value="834">Tanzania, United Republic Of</option>
<option value="764">Thailand</option>
<option value="768">Togo</option>
<option value="772">Tokelau</option>
<option value="776">Tonga</option>
<option value="780">Trinidad And Tobago</option>
<option value="788">Tunisia</option>
<option value="792">Turkey</option>
<option value="795">Turkmenistan</option>
<option value="796">Turks And Caicos Islands</option>
<option value="798">Tuvalu</option>
<option value="800">Uganda</option>
<option value="804">Ukraine</option>
<option value="784">United Arab Emirates</option>
<option value="826">United Kingdom</option>
<option value="840">United States</option>
<option value="858">Uruguay</option>
<option value="860">Uzbekistan</option>
<option value="548">Vanuatu</option>
<option value="862">Venezuela</option>
<option value="704">Viet Nam</option>
<option value="092">Virgin Islands (British)</option>
<option value="850">Virgin Islands (U.S.)</option>
<option value="876">Wallis And Futuna Islands</option>
<option value="732">Western Sahara</option>
<option value="887">Yemen</option>
<option value="891">Yugoslavia</option>
<option value="894">Zambia</option>
<option value="716">Zimbabwe</option>
</select>
</td>
</tr>
<tr>
<td class="info" align="right" width="100">Phone:</td>
<td ALIGN="left" width="100"><input SIZE="20" id="Phone" name="Phone" maxlength="17" value=""></td>
<td class="info" align="right" width="200" colspan="2"><font color="#000000">Extension:</font></td>
<td ALIGN="left" width="100"><input SIZE="10" id="Extension" name="Extension" maxlength="10" value=""></td>
</tr>
<tr>
<td class="info" ALIGN="right" Width="100"><font color="#cc0000">E-Mail Address:</font></td>
<td Colspan="4" ALIGN="left" Width="450">
<input SIZE="40" id="EmailAddress" name="EmailAddress" maxlength="40" value="">
</td>
</tr>
<tr>
<td class="info" ALIGN="right" Width="100">Other Stamp Club Affiliation:</td>
<td Colspan="4" ALIGN="left" Width="450">
<input SIZE="40" id="OtherClub" name="OtherClub" maxlength="40" value="">
</td>
</tr>
<tr>
<td class="info" ALIGN="right" Width="100">
<font color="#CC0000">Your Collecting Interests:</font></td>
<td Colspan="4" ALIGN="left" Width="450">
<textarea name="Interests" rows=5 cols=48 wrap=virtual></textarea>
</td>
</tr>
<tr>
<td class="info" ALIGN="right" Width="100">
<font color="#CC0000">Are you an Existing eUSC Member?</font></td>
<td Colspan="2" ALIGN="left" Width="225">
<input type="radio" value="No" checked name="Member">No</td>
<td Colspan="2" ALIGN="left" Width="225">
<input type="radio" name="Member" value="Yes">Yes</td>
</tr>
<input type=hidden name="submiturl" value="www.iusc.org">
</table>
</td>
</tr>
</table>
<table border="0" width="520">
<tr>
<td ALIGN="right" Width="100"></td>
<td class="info"><font color="#cc0000"><i>* Captions in RED denote required fields.</i></font></td>
</tr>
</table>
<table border="0" width="520">
<tr>
<td width="450" align="right">
<input type="submit" value="Submit" name="Submit">
<input type="reset" value="Reset" name="Reset">
<p align="left">
<font size="2">Clicking 'Submit' should launch your email program
with the appropriate info filled in already. Just select
'Send' to send in your membership request.</font>
</p>
</td>
</tr>
</table>
</form>
PHP文件已完成,但尚未完成:
<?php
print_r($_POST);
echo $_POST["FirstName"];
echo $_POST['LastName'];
echo $_POST['UserID'];
echo $_POST['APSNumber'];
echo $_POST['Address1'];
echo $_POST['PostalCode'];
echo $_POST['EMailAddress'];
echo $_POST['Phone'];
echo $_POST['City'];
echo $_POST['State'];
echo $_POST['Country'];
echo $_POST['Extension'];
echo $_POST['OtherClub'];
echo $_POST['Interests'];
echo $_POST['Member'];
if(isset($_POST['EmailAddress'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "xxxxx@xxxxx.com";
$email_subject = "eUSC Membership Request";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['FirstName']) ||
!isset($_POST['LastName']) ||
!isset($_POST['UserID']) ||
!isset($_POST['Address1']) ||
!isset($_POST['PostalCode']) ||
!isset($_POST['EmailAddress']) ||
!isset($_POST['Phone'])) {
died('We are sorry, but there appears to be a missing entry in the form you submitted.');
}
$FirstName = $_POST['FirstName']; // required
$LastName = $_POST['LastName']; // required
$UserID = $_POST['UserID']; // required
$APSNumber = $_POST['APSNumber']; // required
$Address1 = $_POST['Address1']; // required
$City = $_POST['City']; // required
$State = $_POST['State']; // required
$PostalCode = $_POST['PostalCode']; // required
$Country = $_POST['Country']; // not required
$EmailAddress_from = $_POST['EmailAddress']; // required
$Phone = $_POST['Phone']; // required
$Extension = $_POST['Extension']; // not required
$OtherClub = $_POST['OtherClub']; // not required
$Interests = $_POST['Interests']; // not required
$Member = $_POST['Member']; // not required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$EmailAddress_from)) {
$error_message .= 'The Email UserID you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$FirstName)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$LastName)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($FirstName)."\n";
$email_message .= "Last Name: ".clean_string($LastName)."\n";
$email_message .= "UserID: ".clean_string($UserID)."\n";
$email_message .= "APSNumber: ".clean_string($APSNumber)."\n";
$email_message .= "Address1: ".clean_string($Address1)."\n";
$email_message .= "Address2: ".clean_string($Address2)."\n";
$email_message .= "City: ".clean_string($City)."\n";
$email_message .= "State: ".clean_string($State)."\n";
$email_message .= "PostalCode: ".clean_string($PostalCode)."\n";
$email_message .= "Country: ".clean_string($Country)."\n";
$email_message .= "Email: ".clean_string($EmailAddress_from)."\n";
$email_message .= "Phone: ".clean_string($Phone)."\n";
$email_message .= "Extension: ".clean_string($Extension)."\n";
$email_message .= "OtherClub: ".clean_string($OtherClub)."\n";
$email_message .= "Interests: ".clean_string($Interests)."\n";
$email_message .= "Member: ".clean_string($Member)."\n";
// create email headers
$headers = 'From: '.$EmailAddress_from."\r\n".
'Reply-To: '.$EmailAddress_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<p><a href="index.htm">Back to the Auction!</a></p>
<?php
}
?>
答案 0 :(得分:1)
然而,当我在Firefox中使用Firebug查看URL时,我看到变量(全部15个)已正确填充。
您正在使用$_POST
变量,但上述情况表明变量已附加到网址,此类型为$_GET
如果您想要POST
变量,它们将在标题中发送,并且在URL中对用户不可见。为此,请更改表单方法。
<form method="POST" ...
否则,只需将$_POST
更改为$_GET