注意:未定义的索引:第18行的C:\ wamp \ www \ applicationform.php中的Number_of_Attempts

时间:2014-12-11 15:33:59

标签: php post mysqli

当我尝试提交表单时,我收到上述错误,我是php新手,第一次尝试这个。我看不出代码有什么问题。我必须为工作中的项目完成这项任务

<?php

include "connection2.php";


//Getting the Values from the form
$Firstname = $_POST["Firstname"];
$Lastname = $_POST["Lastname"];
$DOB = $_POST["DOB"];
$Address = $_POST["Address"];
$Telephone_NO = $_POST["Telephone_No"];
$NOK = $_POST["NOK"];
$NOK_Address = $_POST["NOK_Address"];
$vetting_date = $_POST["vetting_date"];
$Clearance_Expiry = $_POST["Clearance_Expiry"];
$Current_Employer = $_POST["Current_Employer"];
$Resubmission = $_POST["Resubmission"];
$Number_of_Attempts = $_POST["Number_of_Attempts"];
$Qual1 = $_POST["Qual_1"];
$Date_Completed_1= $_POST["Date_Completed"];
$Expiry_Date_1 = $_POST["Run_out_date"];
$Qual2 = $_POST["Qual_2"];
$Date_completed_2 = $_POST["Date Completed"];
$expiry_date_2 = $_POST["Run_out_date"];
$Qualification3 = $_POST["Qual_3"];
$Date_completed_3 = $_POST["Date Completed"];
$Expiry_date_3 = $_POST["Run_out_date"];
$Qualification4 = $_POST["Qual_4"];
$Date_Completed_4 = $_POST["Date Completed"];
$Expiry_date_4 = $_POST["Run_out_date"];
$Qualification5 = $_POST["Qual_5"];
$Date_completed_5 = $_POST["Date Completed"];
$Expiry_Date_5 = $_POST["Run_out_date"];
$Qualifictation6 = $_POST["Qual_6"];
$Date_Completed_6 = $_POST["Date Completed"];
$Expiry_date_6 = $_POST["Run_out_date"];
$Qualification7 = $_POST["Qual_7"];
$Date_Completed_7 = $_POST["Date Completed"];
$Expiry_date_7 = $_POST["Run_out_date"];
$Qualification8 = $_POST["Qual_8"];
$Date_completed_8 = $_POST["Date Completed"];
$Expiry_date_8 = $_POST["Run_out_date"];
$Qualification9 = $_POST["Qual_9"];
$Date_completed_9 = $_POST["Date Completed"];
$Expiry_date_9 = $_POST["Run_out_date"];
$Qualification10 = $_POST["Qual_10"];
$Date_completed_10 = $_POST["Date Completed"];
$Expiry_date_10 = $_POST["Run_out_date"];



//inserting to the database
$sql = "INSERT INTO Applicant (Firstname) VALUES (`$Firstname`), (Lastname) VALUES (`$Lastname`), (Address) VALUES (`$Address`), (DOB) VALUES (`$DOB`), (Telephone_No) VALUES (`$Telephone_No`), (NOK) VALUES (`$NOK`), (NOK_Address) VALUES (`$NOK_Address`), (Vetting_Date) VALUES (`$vetting_date`), (Clearance_Expiry) VALUES (`$Clearance_Expiry`), (Current_Employer) VALUES (`$current_employer`), (Resubmission) VALUES (`$Resubmission`), (Number_of_Attempts) VALUES (`$Number_of_Attempts`)";
$sql = "INSERT INTO Qualifaction_Link (Date_Completed) VALUES (`$date_completed_1`), (Run_out_Date) VALUES (`$Expiry_date_1`), (Date_Completed) VALUES (`$date_completed_2`), (Run_out_Date) VALUES (`$Expiry_date_2`), (Date_Completed) VALUES (`$date_completed_3`), (Run_out_Date) VALUES (`$Expiry_date_3`), (Date_Completed) VALUES (`$date_completed_4`), (Run_out_Date) VALUES (`$Expiry_date_4`), (Date_Completed) VALUES (`$date_completed_5`), (Run_out_Date) VALUES (`$Expiry_date_5`), (Date_Completed) VALUES (`$date_completed_6`), (Run_out_Date) VALUES (`$Expiry_date_6`), (Date_Completed) VALUES (`$date_completed_7`), (Run_out_Date) VALUES (`$Expiry_date_7`), (Date_Completed) VALUES (`$date_completed_8`), (Run_out_Date) VALUES (`$Expiry_date_8`), (Date_Completed) VALUES (`$date_completed_9`), (Run_out_Date) VALUES (`$Expiry_date_9`), (Date_Completed) VALUES (`$date_completed_10`), (Run_out_Date) VALUES (`$Expiry_date_10`)";
$sql = "INSERT INTO Qualifaction (Qual_1) VALUES (`$qualification1`), (Qual_2) VALUES (`$Qualification2`), (Qual_3) VALUES (`$Qualification3`), (Qual_4) VALUES (`$Qualification4`), (Qual_5) VALUES (`$Qualification5`), (Qual_6) VALUES (`$Qualification6`), (Qual_7) VALUES (`$Qualification7`), (Qual_8) VALUES (`$Qualification8`), (Qual_9) VALUES (`$Qualification9`), (Qual_10) VALUES (`$Qualification10`)";

  if (!mysqli_query($sql)) {
  die (`Error: ` . mysqli_error());

  }

// if successfully insert data into database, displays message "Successful".
  if($result){
  echo "Successful";
  echo "<BR>";
  echo "<a href='index.php'>Back to Home page page</a>";
}

  else {
  echo "ERROR";
}
?> 
 //closing the connection
 mysqli_close()
 ?>

这是所有代码

这是表单代码

网络战

<header> 
    <h1 align="center"> Cyber Warfare Application Form </h1>
</header>

<center><img  src="cyberwarfareimage1.png" alt="Squadron logo" style="width:300px;height:300px" style="middle"> </center>

<body>
 <table border="1">
<tr>
  <td><a href="index.php"> Home Page </a>
  </table>
  <br>
  <br>
  <br>


    <form action=applicationform.php method="post"/>
            First name:<br>
            <input type="text" name="Firstname">
        <br>
        <br>
            Last Name:<br>
            <input type="text" name="Lastname">
        <br>
        <br>
            Date Of Birth YYYY/MM/DD:<br>
            <input type="Date" name="DOB">
        <br>
        <br>
            Address:<br>
            <input type="text" name="Address">
        <br>
        <br>
            Telephone Number:<br>
            <input type="text" name="Telephone_No">
        <br>
        <br>
            Next Of Kin:<br>
            <input type="text" name="NOK">
        <br>
        <br>
          Next Of Kin Address:<br>
            <input type="text" name="NOK_Address">
        <br>
        <br>
            Vetting Date YYYY/MM/DD:<br>
            <input type="date" name="vetting_date">
        <br>
        <br>
            Clearance Expiry YYYY/MM/DD:<br>
            <input type="date" name="Clearance_Expiry">
        <br>
        <br>
            Current Employer:<br>
            <input type="text" name="Current_Employer">
        <br>
        <br>
            Are you Resubmitting:<br>
            <input type="radio" name="Resubmission" value="Yes" >Yes
        <br>
        <input type="radio" name="Resubmission" value="No" checked>No
        <br>
        <br>
            If Yes How Many Previous Attempts:<br>
            <input type="number" name="Number_of_Attempts">
        <br>
        <br>
            Qualification 1:<br>
            <input type="text" name="Qual_1">
        <br>
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_1">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_1">
        <br>
        <br>
             Qualification 2 :<br>
            <input type="text" name="Qual_2">
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_2">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_2">
        <br>
        <br>
             Qualification 3:<br>
            <input type="text" name="Qual_3">
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_3">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_3">
        <br>
        <br>
             Qualification 4:<br>
            <input type="text" name="Qual_4">
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_4">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_4">
        <br>
        <br>
            Qualification 5:<br>
            <input type="text" name="Qual_5">
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_5">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_5">
        <br>
        <br>
            Qualification 6:<br>
            <input type="text" name="Qual_6">
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_6">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_6">
        <br>
        <br>
            Qualification 7:<br>
            <input type="text" name="Qual_7">
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_7">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_7">
        <br>
        <br>
            Qualification 8:<br>
            <input type="text" name="Qual_8">
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_8">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_8">
        <br>
        <br>
            Qualification 9:<br>
            <input type="text" name="Qual_9">
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_9">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_9">
        <br>
        <br>
            Qualification 10:<br>
            <input type="text" name="Qual_10">
        <br>
            Date Completed YYYY/MM/DD:<br>
            <input type="date" name="date_completed_10">
        <br>
            Expiry Date YYYY/MM/DD:<br>
            <input type="date" name="Run_out_date_10">
        <br>
        <textarea name="why"  rows="20" cols="40">Why do you want to join? In 150 words or less</textarea>
        <br><br>
        <input type="Submit" Value="Submit">
        <input type="reset" value="Reset">
    </form> 

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

在这种情况下,这意味着POST超全局不包含此值,即表单不包含该值或输入字段设置为&#34;禁用&#34;。