HTML表格& Godaddy PHP

时间:2015-12-10 20:01:30

标签: forms

尝试在HTML&中设置表单PHP&然后在爸爸身上使用它,但它没有用。我在PHP方面非常新。我确信我的代码需要的不仅仅是我的代码。我不做或不知道的是什么?就像我说我是.PHP的新手。无论我能得到什么帮助都将非常感激。

这里是HTML表单代码:

NSUserDefaults.standardUserDefaults().setObject(<array>, forKey:<keyName>)

这里是PHP代码:

<form id="ApplicantForm" action="gdform.php" method="post" >


<div class="formname">First Name<br><input name="first Name" type="text" id="first Name" title="First Name" size="10"></div>

<div class="formname">M.I.<br><input name="MI" type="text" id="MI" title="Middle Initial" size="2" maxlength="1"></div>

<div class="formname">Last <br><input name="Last" type="text" required id="Last" title="Last Name" size="10"></div>

<div class="formname">Suffix<br><select>
  <option selected>I</option>
  <option>II</option>
  <option>III</option>
  <option>IV</option>
  <option>Jr.</option>
  <option>Sr.</option>
</select></div>
<br>
<div class="formInfo">email <br><input name="email" type="text" id="emailAddr" title="email" size="40"></div><br>
<div class="formInfo">Address <br><input name="address" type="text" required id="Addr1" title="Address" size="40"></div><br>
<div class="formInfo">City <br><input name="City" type="text" required id="AddrCity" title="City" size="40"></div><br>
<div class="formInfo">State <br><input name="State" type="text" required id="AddrState" title="State" size="40"></div><br>
<div class="formInfo">Zip Code<br><input name="Zip" type="text" required id="AddrZip" title="Zip" size="20"></div>

<div class="formInfo">Country<br><input name="Country" type="text" required id="country" title="Country" size="20"></div>
<br><br>
<div class="formQues">I wish to keep my contact Information confidential <br>

    <label>
      <input type="radio" name="KeepInfoConfidential1" value="InfoConfidential"  id="InfConfidential1_0">
      Yes</label>

    <label>
      <input type="radio" name="KeepInfoConfidential1" value="InfoConfidential" id="InfConfidential1_1">
      No</label>
    </div><br>
    <div class="PhoneInfo">Phone Number<br><input name="PhoneNumber" type="text" required id="PhoneNo" title="Phone Number" size="15"></div>

    <div class="PhoneInfo"><br>
   <select name="PhoneNumber" id="PhoneNumber" title="PhoneNumber">
     <option>Mobile</option>
     <option>Home</option>
     <option>Fax</option>
   </select> 
   </div>
    <div class="PhoneInfo">Alt Number<br><input name="AlternateNumber" type="text" id="AltNo" title="Alternate Number" size="15"></div><div class="PhoneInfo"><br>
   <select name="AlternateNumber" id="AlternateNumber" title="AlternateNumber">
     <option>Mobile</option>
     <option>Home</option>
     <option>Fax</option>
   </select> 
   </div><br>


<div class="formQues">I wish to keep my Phone Numbers confidential <br>

    <label>
      <input type="radio" name="KeepNumbersConfidential1" value="NumbersConfidential"  id="KeepNumbConf">
      Yes</label>

    <label>
      <input name="KeepNumbersConfidential1" type="radio" id="KeepNumbConf2" value="NumbersConfidential" checked>
      No</label>
    </div><br>
<div class="BestTime">Best time of the day to reach you<br>
   <select required>
     <option>Morning</option>
     <option>Mid Day</option>
     <option>Evening</option>
   </select> </div><br>

   <div class="formQues">I will require Visa Sponsorship <br>

    <label>
      <input type="radio" name="VisaSpon1" value="VisaSponsorship"  id="VisaSpons1">
      Yes</label>

    <label>
      <input name="VisaSpon1" type="radio" id="VisaSpons2" value="VisaSponsorship" checked>
      No</label>
    </div><br>

 <div class="formQues">Are You Willing To Relocate? <br>

    <label>
      <input name="relocate" type="radio"  id="WillingToRelocate1" value="WillYouRelocate" checked>
      Yes</label>

    <label>
      <input type="radio" name="relocate" value="WillYouRelocate" id="WillingToRelocate2">
      No</label>
    </div>   <br>

 <div class="BestTime">Type of facility you desire/willing to work<br>
   <select name="DesiredFacility"  required id="DesiredFacility" title="Desired Facility">
     <option>Private Physician Office</option>
     <option>Hospital</option>
     <option>Long Term Care/Nursing Home</option>
     <option>Community Centers (i.e. CVS, Walgreens, Little Clinic)</option>
   </select> 
   </div> <br>  

   <input name="Submit" type="submit" id="Submit" title="Submit" value="Submit"><br>
</form>

1 个答案:

答案 0 :(得分:0)

我认为你的问题在于你的问题。本节特别说明:

$fp = fopen($file,"w");
while (list ($key, $val) = each ($query_vars)) {
 fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
 fputs($fp,"$val\n");
 fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
 if ($key == "redirect") { $landing_page = $val;}
}
fclose($fp);

对我来说看起来更像是c ++编码?

无论如何,我建议将该部分重写为这样的部分:

$output = "";
foreach($query_vars as $key => $value){
  $output .= "<GDFORM_VARIABLE NAME=" . $key. " START>\n" . $val . "\n<GDFORM_VARIABLE NAME=" . $key . " END>\n";
}
file_put_contents($file, $output);

这样就无需单独打开和关闭文件,只需将其全部保留到&#34; file_put_contents()&#34;处理它。

此外,我还不完全确定$ query_vars是否超出范围。为了安全起见,我会改写:

$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
  $query_vars = $_GET;
} elseif ($request_method == "POST"){
  $query_vars = $_POST;
}

成:

$query_vars = ($request_method == "GET" ? $_GET : $_POST);

此外,您使用以下方式进行操作:

reset($query_vars);

不是必需的。

为了将来参考,php具有出色的错误报告功能。只需将其添加到文件顶部:

error_reporting(E_ALL);

然后运行该页面。你应该能够解决这个问题。